6 Data Input and Output
6 Data Input and Output
The above examples would print exactly what has been capsuled in the
quotation marks (together with the effect of any escape sequences).
However, there are times we would want to print values that are stored in
variables (memory).
To do so we would have to use control strings.
For example:
int age = 50; //the variable is age and the value stored is 50
printf(“%d \n”, age); // to print the value 50 as an integer
printf(“I am %d years old”, age); // printing the age from memory
For example:
int count = 4; //the variable is count and the value stored is 4
float weight = 90.61;
printf(“Angela who bought %d oranges weighs %g kilograms”,
count, weight);
// combining various variables in one print statement
THE END
Any Questions?
Contact: [email protected] or [email protected]