Home / C Programming / Control Instructions :: Discussion

Discussion :: Control Instructions

  1. What will be the output of the program?

     #include
     int main()
     {   
        float a = 0.7;   
        if(0.7 > a)         
           printf("Hi\n"); 
        else     
           printf("Hello\n");  
        return 0;
     } 
    

  2. A.

    Hi

    B.

    Hello

    C.

    Hi Hello

    D.

    None of above

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    if(0.7 > a) here a is a float variable and 0.7 is a double constant. The double constant 0.7 is greater than the float variable a. Hence the if condition is satisfied and it prints 'Hi'
    Example:

    #include int main() {     float a=0.7;     printf("%.10f %.10f\n",0.7, a);     return 0; } 

    Output:
    0.7000000000 0.6999999881


Be The First To Comment