with each % indicating where one of the other (second, third, ...) arguments is to be substituted, and in what form it
is to be printed. For instance, %d specifies an integer argument
augment each %d
For Instance
printf("%3d'F%6d'C ",Fahrenheit,Celsius);
to print the first number of each line in a field three digits wide, and the second in a field six digits wide,
The printf conversion specification %3.0f says that a floating-point number (here fahr) is to be printed at
least three characters wide, with no decimal point and no fraction digits. %6.1f describes another number
(celsius) that is to be printed at least six characters wide, with 1 digit after the decimal point. The output looks
like this:
printf("%3.1f'F %6.1f'C ",Fahrenheit,Celsius); 0.0'F -17.8'C 5.0'F -15.0'C 10.0'F -12.2'C 15.0'F -9.4'C
printf("%3.0f'F %6.1f'C ",Fahrenheit,Celsius); 0'F -17.8'C 5'F -15.0'C 10'F -12.2'C 15'F -9.4'C
printf("%3.2f'F %6.3f'C ",Fahrenheit,Celsius); 0.00'F -17.778'C 5.00'F -15.000'C 10.00'F -12.222'C 15.00'F -9.444'C 20.00'F -6.667'C 25.00'F -3.889'C 30.00'F -1.111'C 35.00'F 1.667'C 40.00'F 4.444'C 45.00'F 7.222'C 50.00'F 10.000'C 55.00'F 12.778'C 60.00'F 15.556'C 65.00'F 18.333'C 70.00'F 21.111'C 75.00'F 23.889'C 80.00'F 26.667'C 85.00'F 29.444'C 90.00'F 32.222'C 95.00'F 35.000'C 100.00'F 37.778'C 105.00'F 40.556'C
Width and precision may be omitted from a specification:
%6f says that the number is to be at least six characters
wide;
%.2f specifies two characters after the decimal point, but the width is not constrained;
and %f merely says
to print the number as floating point.
Among others, printf also recognizes %o for octal, %x for hexadecimal, %c for character, %s for character
string and %% for itself %.
uses %f for both float and double; %.0f suppresses the printing of the decimal point and the
fraction part, which is zero.