#include <stdio.h>
int main()
{
float a = 12.67;
printf("%f\n", a);
printf("%e\n", a);
return 0;
}
12.670000
1.267000e+01
The %f format specifier is implemented for representing fractional values. This is implemented within printf() function for printing the fractional or floating value stored in the variable. Whenever you need to print any fractional or floating data, you have to use %f format specifier.
printf("%f", <variable name>); First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.