352 Chapter 16 Input and Output Operations in C
Program 16.1 Output
Integers:
425 651 1a9 425
1a9 1A9 0x1a9 0X1A9
+425 425 0000425 0000425
17 21 11 17
61817 170571 f179 61817
75000 222370 124f8 75000
1311768465173141112 110642547402215053170 1234567812345678 1311768465173141112
Floats and Doubles:
12.978000 1.297800e+01 12.978
12.98 1.30e+01
13 1e+01
12.98 1.30e+01
-97.458300 -9.745830e+01 -97.4583
-97.458
-97.46
Characters:
X
X X
58
Strings:
abcdefghijklmnopqrstuvwxyz
abcde
abcdefghijklmnopqrstuvwxyz
abcde
abcde
Pointers:
0xbffffc20 0xbffffbf0
This is fun.
c1 = 4, c2 = 12
It’s worthwhile to take some time to explain the output in detail.The first set of output
deals with the display of integers:short,long,unsigned, and “normal”ints.The first
line displays iin decimal (%i), octal (%o), hexadecimal (%x), and unsigned (%u) formats.
Notice that octal numbers are not preceded by a leading 0 when they are displayed.
The next line of output displays the value of iagain. First,iis displayed in hexadeci-
mal notation using %x.The use of a capital X(%#X) causes printfto use uppercase letters
A–F instead of lowercase letters when displaying numbers in hexadecimal.The #modifi-
er (%#x) causes a leading 0xto appear before the number and causes a leading 0Xto
appear when the capital Xis used as the conversion character (%#X).