Home » C Programming » Data Types » Question
  1. 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 ;
    }
    1. 4.320000e + 001 43.200001 43.2
    2. 4.3 43.22 43.21
    3. 4.3e 43.20f 43.00
    4. 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.



Your comments will be displayed only after manual approval.