edited by
1,109 views
1 votes
1 votes
void ab()
{
    auto int a;
    static int s= 5;
    a = ++s;
    printf("%d%d",a,s);
    if(a<= 7)
    ab();
    printf("%d%d",a,s);
}
void main()
{
    ab();
}



According to me answer should be- 667788887766 but the answer is - 667788887868. Please explain

edited by

1 Answer

Best answer
2 votes
2 votes

Ans-667788887868

a is local variable and s is static variable so scope of local variable is local and it will destroy after function is over and scope of static variable is throughout the program.

selected by

Related questions

26
views
1 answers
0 votes
harshitraj12 asked 14 hours ago
26 views
Find Output of below Code#include<stdio.h>int sum(int n) { n = 3; if (n == 2) return 2; return sum(n-1)*n ;}int main() { printf("%d\n", sum(5) ); return 0}
262
views
2 answers
0 votes
Debargha Mitra Roy asked Apr 10
262 views
What is the output of the below code?#include <stdio.h> void main() { static int var = 5; printf("%d ", var--); if (var) main(); }a. 1 2 3 4 5b. 1c. 5 4 3 2 1d. Error
1.3k
views
3 answers
3 votes
Laxman Ghanchi asked May 19, 2023
1,275 views
#include<stdio.h> void print(int n) { printf("Hello "); if(n++ == 0) return ; print(n); n++; } int main() { void print(); print(-4); }How many times printf execute?? And How ??
767
views
1 answers
0 votes
Laxman Ghanchi asked May 19, 2023
767 views
#include<stdio.h>void print(int n){ printf("Hello "); if(n++ == 0) return ; print(n); n++;}int main(){ void print(); print(-4);}