A

Admin • 833K Points
Coach

Q. Determine Output:

Code:
void main()
{
static int var = 5;
printf("%d ", var--);
if(var)
main();
}
  • (A) 5 5 5 5 5
  • (B) 5 4 3 2 1
  • (C) Infinite Loop
  • (D) None of These
  • Correct Answer - Option(B)
  • Views: 21
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

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.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.