Chapter - 4
Chapter - 4
Programming
Chapter 4
⚫ In this case, both the field width and the precision are
given as arguments which will supply the values for w
and p. For example,
printf("%*.*f ",7,2,number);
⚫ is equivalent to
printf (“%7.2f " ,number);
⚫ The advantage of this format is that the values for
width and precision may be supplied at run time, thus
making the format a dynamic one.
9/25/2022 Ref: Programming in ANSI C by 34
E.Balagurusamy
Output of Real numbers
⚫ For example, the above statement can be used as
follows:
int width = 7;
int precision = 2;
printf("%*.*P,” width, precision, number);