C Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - Point Out Correct Statements (Q.No. 5)
                   
                                       
                                5.
Which of the following statements are correct about the below program?
 
                                    #include<stdio.h>
int main()
{
    int i = 0;
    i++;
    if(i <= 5)
    {
        printf("IndiaBIX\n");
        exit(0);
        main();
    }
    return 0;
}
Answer: Option
                                                    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 <= 5) becomes if(1 <= 5) here we are checking '1' is less than or equal to '5'. Hence the if condition is satisfied.
Step 4: printf("IndiaBIX\n"); It prints "IndiaBIX"
Step 5: exit(); terminates the program execution.
Hence the output is "IndiaBIX".
Discussion:
16 comments Page 2 of 2.
                
                        Shiwam said: 
                         
                        1 decade ago
                
                It also gives error that exit() was not declared in this scope.
                
                        Chaitali said: 
                         
                        1 decade ago
                
                Can we call main() function any where in the program?
                
                        Vikas said: 
                         
                        1 decade ago
                
                But after exit() main() will be executed or not?
                
                        Pikachu said: 
                         
                        1 decade ago
                
                Why option C can not be answer?
Please explain.
                Please explain.
                        Renonsz said: 
                         
                        9 years ago
                
                Option C is also the correct answer.
                
                        Amit said: 
                         
                        2 decades ago
                
                Can main have a call to itself?
                Post your comments here:
 
            
        Quick links
                            Quantitative Aptitude
                                    
                                    Verbal (English)
                                    
                                    Reasoning
                                    
                                Programming
                                    
                                    Interview
                                    
                                     Placement Papers