Precision specifier and justifying output for printf() function in C

A precision specifier is a period followed by an integer in between the percentage sign and the format code. For Example: %6.2f displays s number 6 characters wide with 42 decimal places. For format specifier %g it specifies number of significant digits, for strings it specifies the maximum field length., for integers it specifies minimum number of digits that will appear. Zeroes are used to add more digits to a number.

Justifying output: Every default output is right justified. To make it left justified we have to place a minus sign after %. For Example: %−6.4f left justifies a floating point number with 4 decimal places in a 6 character field

Leave a Reply