Multiple choice

What will be the output of the following C code? void main() { static int t=7; printf(%d,t); if(t--) main(); }

  1. 76543210

  2. 7654321

  3. 7654321 - 1

  4. Infinite loop

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

First printf() will print 7, then if condition gets true due to non-zero integer and t will decrement and main() call recursively. Again printf() will print 6, then if condition gets true due to non zero integer and t will decrement and main() call recursively and so on. If condition gets false, when value of t will be 0. Hence, output will be 76543210. (The static variable always retains its value)