Data Types


  1. Which of the following is the correct output for the program given below?
    #include <stdio.h>
    int main ( )
    {
    double d = 2.25;
    printf ("%e", d);
    printf ("%f", d);
    printf ("%g".d);
    printf ("%lf\n", d);
    return 0 ;
    }









  1. View Hint View Answer Discuss in Forum

    250000e + 000 2.250000 2.25 2.250000

    Correct Option: C

    printf("%e,", d); Here '%e' specifies the "Scientific Notation" format. So, it prints the 2.25 as 2.250000e+000.

    printf("%f,", d); Here '%f' specifies the "Decimal Floating Point" format. So, it prints the 2.25 as 2.250000.

    printf("%g,", d); Here '%g' "Use the shorter of %e or %f". So, it prints the 2.25 as 2.25.

    printf("%lf,", d); Here '%lf' specifies the "Long Double" format. So, it prints the 2.25 as 2.250000.


  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. View Hint View Answer Discuss in Forum

    4.320000e + 001 43.200001 43.2

    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.



  1. Which of the following statements are correct about the program given below?
    #include <stdio.h>
    int main ()
    {
    float k = 0.7;
    if (k < 0.7)
    printf ("C\n");
    else
    printf ("C++\n");
    return 0 ;
    }









  1. View Hint View Answer Discuss in Forum

    if(k < 0.7) here k is a float variable and 0.7 is a double constant. The float variable k is less than double constant 0.7. Hence the if condition is satisfied and it prints 'C'

    Correct Option: A

    if(k < 0.7) here k is a float variable and 0.7 is a double constant. The float variable k is less than double constant 0.7. Hence the if condition is satisfied and it prints 'C'


  1. Which of the following is the correct output for the program given below?
    #include <stdio.h>
    #include <math.h>
    int main ( )
    {
    printf ( "%f\n" ,sqrt (49.0));
    return 0 ;
    }









  1. View Hint View Answer Discuss in Forum

    It prints the square root of 49 in the float format(i.e 7.000000).

    Correct Option: C

    It prints the square root of 49 in the float format(i.e 7.000000).



  1. Which of the following is the correct output for the program given below?
    #include<stdio.h>
    int main ( )
    {
    float *p;
    printf ( "%d\n " , sizeof ( p ) );
    return 0 ;
    }









  1. View Hint View Answer Discuss in Forum

    2 in 16-bit compiler like TC/TC++, 4 in 32-bit compiler like Visual studio or gcc

    Correct Option: A

    2 in 16-bit compiler like TC/TC++, 4 in 32-bit compiler like Visual studio or gcc