C | Storage Classes and Type Qualifiers | Question 3

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h>
int main()
{
    static int i=5;
    if (--i){
        printf("%d ",i);
        main();
    }
}

chevron_right


(A) 4 3 2 1
(B) 1 2 3 4
(C) 4 4 4 4
(D) 0 0 0 0


Answer: (A)

Explanation: Since i is static variable, it is shared among all calls to main(). So is reduced by 1 by every function call.

Quiz of this Question



My Personal Notes arrow_drop_up