Q. Which of the following is the correct output for the program given below?
Code:#include <stdio.h>
int main ( )
{
float n = 5.375 ;
printf("%f %e %E\n" , n, n, n) ;
return 0 ;
}
β
Correct Answer: (C)
5.375000 5.375000e+000 5.375000E+000
Explanation:
The printf() function is used to print a floating-point number in different formats:
- %f β Prints the number in decimal notation (default floating-point format).
- %e β Prints the number in scientific notation (lowercase 'e').
- %E β Prints the number in scientific notation (uppercase 'E').
Breakdown of Output:
For n = 5.375:
- %f β 5.375000 (default 6 decimal places)
- %e β 5.375000e+000
- %E β 5.375000E+000
Thus, the output is:
5.375000 5.375000e+000 5.375000E+000