Home / C Programming / Control Instructions :: Discussion

Discussion :: Control Instructions

  1. What will be the output of the program?

    #include
     int main()
     {   
        int x = 3;   
        float y = 3.0;    
        if(x == y)       
           printf("x and y are equal");      
        else     
           printf("x and y are not equal");  
       return 0; 
     } 
    

  2. A.

    x and y are equal

    B.

    x and y are not equal

    C.

    Unpredictable

    D.

    No output

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    Step 1: int x = 3; here variable x is an integer type and initialized to '3'.
    Step 2: float y = 3.0; here variable y is an float type and initialized to '3.0'
    Step 3: if(x == y) here we are comparing if(3 == 3.0) hence this condition is satisfied.
    Hence it prints "x and y are equal".


Be The First To Comment