Home / C Programming / Control Instructions :: Find Output of Program

C Programming :: Control Instructions

  1. What will be the output of the program?

     #include
     int main() 
     {   
         int k, num = 30; 
         k = (num 10) ? 100 : 200;       
         printf("%d\n", num); 
         return 0; 
     } 
    

  2. A.

    200

    B.

    30

    C.

    100

    D.

    500

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the program?

     #include 
     int main()
     {   
        int a = 300, b, c;   
        if(a >= 400)     
             b = 300;     
        c = 200;     
        printf("%d, %d, %d\n", a, b, c);       
        return 0; 
    } 
    

  4. A.

    300, 300, 200

    B.

    Garbage, 300, 200

    C.

    300, Garbage, 200

    D.

    300, 300, Garbage

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of the program?

     #include
     int main()
     {    
        int x=1, y=1;   
        for(; y; printf("%d %d\n", x, y))     
        {     
             y = x++ 5;  
        } 
        printf("\n");   
        return 0; 
     } 
    

  6. A.

    2 1
    3 1
    4 1
    5 1
    6 1
    7 0

    B.

    2 1
    3 1
    4 1
    5 1
    6 1

    C.

    2 1
    3 1
    4 1
    5 1

    D.

    2 2
    3 3
    4 4
    5 5

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be the output of the program?

     #include 
     int main()
     {     
         int i = 5; 
         while(i-- >= 0)           
            printf("%d,", i);  
        i = 5;   
        printf("\n");   
        while(i-- >= 0)         
            printf("%i,", i);       
        while(i-- >= 0)           
           printf("%d,", i); 
        return 0;
     } 
    

  8. A.

    4, 3, 2, 1, 0, -1
    4, 3, 2, 1, 0, -1

    B.

    5, 4, 3, 2, 1, 0
    5, 4, 3, 2, 1, 0

    C.

    Error

    D.

    5, 4, 3, 2, 1, 0
    5, 4, 3, 2, 1, 0
    5, 4, 3, 2, 1, 0

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the program?

    #include 
     int main() 
     { 
         int i=3;   
         switch(i)  
         {         
             case 1:                 
                printf("Hello\n");         
             case 2:             
                printf("Hi\n");         
             case 3:             
                continue;         
             default:             
                 printf("Bye\n");  
        }   
        return 0; 
    } 
    

  10. A.

    Error: Misplaced continue

    B.

    Bye

    C.

    No output

    D.

    Hello Hi

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program?

    #include
     int main() 
     {    
        int x = 10, y = 20;   
        if(!(!x) && x)     
            printf("x = %d\n", x);      
        else    
           printf("y = %d\n", y);       
       return 0;
     } 
    

  12. A.

    y =20

    B.

    x = 0

    C.

    x = 10

    D.

    x = 1

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program?

    #include 
     int main()
     {     
        int i=4;  
        switch(i)   
        {       
          default:               
             printf("This is default\n");           
          case 1:     
             printf("This is case 1\n");               
             break;      
          case 2:       
             printf("This is case 2\n");            
             break;    
          case 3:        
             printf("This is case 3\n");       
       }   
       return 0; 
    } 

     

  14. A.

    This is default
    This is case 1

    B.

    This is case 3
    This is default

    C.

    This is case 1
    This is case 3

    D.

    This is default

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the program?

     #include 
     int main()
     {    
         int i = 1;   
         switch(i)    
         {       
             printf("Hello\n");     
             case 1:         
                 printf("Hi\n");         
                 break;  
             case 2:      
                 printf("\nBye\n");     
                 break;    
         }     
         return 0;
      } 
    

     

  16. A.

    Hello
    Hi

    B.

    Hello
    Bye

    C.

    Hi

    D.

    Bye

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the program?

    #include 
     int main()
     {    
           char j=1;  
           while(j 5)   
           {        
                printf("%d, ", j);     
                j = j+1;     
            }  
             printf("\n");   
             return 0;
       } 
    

  18. A.

    1 2 3 ... 127

    B.

    1 2 3 ... 255

    C.

    1 2 3 ... 127 128 0 1 2 3 ... infinite times

    D.

    1, 2, 3, 4

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the program?

     #include 
     int main()
     {  
         int x, y, z;  
         x=y=z=1;   
         z = ++x || ++y && ++z;    
         printf("x=%d, y=%d, z=%d\n", x, y, z);    
         return 0;
     } 
    

  20. A.

    x=2, y=1, z=1

    B.

    x=2, y=2, z=1

    C.

    x=2, y=2, z=2

    D.

    x=1, y=2, z=1

    View Answer

    Workspace

    Discuss Discuss in Forum