Home / C Programming / Control Instructions :: Discussion

Discussion :: Control Instructions

  1. Which of the following statements are correct about the below program?

    #include 
     int main() 
     {   
          int i = 0;   
          i++;    
          if(i 5)    
          {        
             printf("FresherGate\n");    
             exit(0);  
             main();   
         }    
         return 0; 
     } 
    

  2. A.

    The program prints 'FresherGate' 5 times

    B.

    The program prints 'FresherGate' one time

    C.

    The call to main() after exit() doesn't materialize.

    D.

    The compiler reports an error since main() cannot call itself.

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    Step 1: int i = 0; here variable i is declared as an integer type and initialized to '0'(zero).
    Step 2: i++; here variable i is increemented by 1(one). Hence, i = 1
    Step 3: if(i becomes if(1 here we are checking '1' is less than or equal to '5'. Hence the if condition is satisfied.
    Step 4: printf("FresherGate\n"); It prints "FresherGate"
    Step 5: exit(); terminates the program execution.

    Hence the output is "FresherGate".


Be The First To Comment