C - Operators - Discussion

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

 



Q.

main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}

A. 5 4 0 0 0 B. 5 4 3 0 0
C. 5 4 3 2 0 D. 5 4 3 2 1

Answer: Option D
Explaination:

 


When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively



Discussion

Your Comments Goes here...
NameDiscussion