Sams Teach Yourself C in 21 Days

(singke) #1
Working with the Screen, Printer, and Keyboard 367

14


Outputting a number with different field widths.
10000.123047
10000.123047
10000.123047
10000.123047
10000.123047
Press Enter to continue...

Use the * field width specifier to obtain field width
from a variable in the argument list.
10000.123047
10000.123047
10000.123047
10000.123047
10000.123047
Press Enter to continue...

Include leading zeros.

10000.123047
10000.123047
00010000.123047
0000000010000.123047
000000000000010000.123047

Press Enter to continue...

Display in octal, decimal, and hexadecimal.
Use # to precede octal and hex output with 0 and 0X.
Use - to left-justify each value in its field.
First display column labels.
Decimal Octal Hexadecimal
1 01 0X1
2 02 0X2
3 03 0X3
4 04 0X4
5 05 0X5
6 06 0X6
7 07 0X7
8 010 0X8
9 011 0X9
10 012 0XA
11 013 0XB

OUTPUT

22 448201x-CH14 8/13/02 11:12 AM Page 367

Free download pdf