C Programming Exercise-02
C Programming Exercise-02
Exercise-1 : What output do the following calls of the printf produce? (Use '*' to indicate one
space)
.21 5.6 78
what will be the values of i, x, and j after the call? Assume that x and j are int variables and i is an
float variable.
21 5.6 78
what will be the values of i, x, and j after the call? Assume that x and i are int variables and j is an
float variable.
Exercise-4 : Write call of the printf that displays a float variable numf in the following format.
Exponential notation; left-justified in a field of size 6; 3 digit after the decimal point
Exercise-5 : Write call of the printf that displays a float variable numf in the following formats.
Fixed decimal notation; right-justified in a field of size 8; no digits after the decimal point.
Reference:K. N. King “C Programming: A Modern Approach”, Norton Publishing, 2nd Edition, 2008. 1 /2
Exercise-6 : Write call of the scanf that reads a floating-point number and stores in variable
number.
Exercise-7 : Write call of the scanf that reads a floating-point number and stores in variable
num1 and an integer store in variable num2.
Exercise-8 : Write call of the scanf that reads two integers in format 5-6 store in variable value1
and value2.
Exercise-9 : Suppose that two float variables num1 and num2 are 5.25 and 3.1 respectively.
Write call of the printf that displays
5.2500-3.1000=2.15
Exercise-10 : Suppose that two int variables num1 and num2 are 45 and 30 respectively. Write
call of the printf that displays
****45
****30
+_____
****75
Reference:K. N. King “C Programming: A Modern Approach”, Norton Publishing, 2nd Edition, 2008. 2 /2