C - Functions - Discussion

You Are Here :: Home > C > Functions - Discussion

 



Q.

What will be the output of the program?

#include
#include
int main()
{
int i=0;
i++;
if(i<=5)
{
printf("careersadda");
exit(1);
main();
}
return 0;
}

A. Prints "careersadda" 5 times B. Function main() doesn't calls itself
C. Infinite loop D. Prints "careersadda"

Answer: Option D
Explaination:

i++; Here variable i is increemented by 1. Hence i becomes '1'(one).

if(i<=5) becomes if(1 <=5). Hence the if condition is satisfied and it enter into if block statements.It prints "careersadda".



Discussion

Your Comments Goes here...
NameDiscussion