Explanation: The output will be ______15.20000, where _ has been used to represent space here. The program will print a floating-point number with a width of at least 14 and since no precision has been specified, it will take the default precision of 6 decimal point for format specifier “f”.
The symbol * can be used with a format specifier to replace the width or precision. Here it has been used to replace the width. The general format for %f can be seen as %(width). (precision)f. When * is used to specify width or precision. Let see a C code for the same.
#include <stdio.h>
int main()
{
int pos = 14;
float data = 15.2;
printf("%*.*f",pos,2,data);
return 0;
}
Output:
print 15.200000 with 6 spaces.
Explanation: The output will be ______15.20000, where _ has been used to represent space here. The program will print a floating-point number with a width of at least 14 and since no precision has been specified, it will take the default precision of 6 decimal point for format specifier “f”.
The symbol * can be used with a format specifier to replace the width or precision. Here it has been used to replace the width. The general format for %f can be seen as %(width). (precision)f. When * is used to specify width or precision. Let see a C code for the same.
Output:
print 15.20 with spaces.
need an explanation for this answer? contact us directly to get an explanation for this answer