What would the output of c program

 

#include<stdio.h>
int main()
{
    static int i=5;
    if(--i){
        main();
        printf("%d ",i);
    }   
}
Asked on January 30, 2020 in program.
Add Comment
1 Answer(s)

Output: 0 0 0 0

Explanation:

Since i is a static variable and is stored in Data Section, all calls to main share same i.

Answered on January 30, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.