Input and Output Statement
Input and Output Statement
Input and Output Statement
Chapter 3:Operators and Expressions| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2006 | Last Updated: July 2006 Slide 1
Input
&
Output
Operations
The input Object
• Standard command for input prompt
• Used to call and read input from keyboard
• Input is stored in one or more variables
input command
Reading Strings with input
• Can be used to read and store in a string.
• Display result:
length = 10
height = 11
area = length * height
• Type Coercion:
automatic conversion of an operand to
another data type
• Promotion:
convert to a higher type
• Demotion:
convert to a lower type
Example
Output: 3.4641016151377544
Library & Extension math
Hand trace a program: act as if you are Useful to locate logic or mathematical
the computer, executing a program: errors
step through and ‘execute’ each statement, one-by-
one
record the contents of variables after statement
execution, using a hand trace chart (table)