-
Which of the following is the correct output for the program given below?
#include <stdio.h>
int main ( )
{
float f = 43.20;
printf ("%e", f);
printf ("%f", f);
printf ("%g \n" , f);
return 0 ;
}
-
- 4.320000e + 001 43.200001 43.2
- 4.3 43.22 43.21
- 4.3e 43.20f 43.00
- Error
Correct Option: A
printf("%e,", d); Here '%e' specifies the "Scientific Notation" format. So, it prints the 43.20 as 43.200000e+000.
printf("%f,", d); Here '%f' specifies the "Decimal Floating Point" format. So, it prints the 43.20 as 43.200001.
printf("%g,", d); Here '%g' "Use the shorter of %e or %f". So, it prints the 43.20 as 43.20.