Discussion :: Functions
-
What will be the output of the program?
#include
int main() { int i=0; i++; if(i5) { printf("FRESHERGATE"); exit(1); main(); } return 0; }
A.
Prints "FRESHERGATE" 5 times |
B.
Function main() doesn't calls itself |
C.
Infinite loop |
D.
Prints "FRESHERGATE" |
Answer : Option D
Explanation :
Step 1: int i=0; The variable i is declared as in integer type and initialized to '0'(zero).
Step 2: i++; Here variable i is increemented by 1. Hence i becomes '1'(one).
Step 3: if(i becomes if(1 . Hence the if condition is satisfied and it enter into if block statements.
Step 4: printf("IndiaBIX"); It prints "IndiaBIX".
Step 5: exit(1); This exit statement terminates the program execution.
Hence the output is "IndiaBIx".
Be The First To Comment