in Programming in C edited by
209 views
0 votes
0 votes

 

#include<stdio.h>
int K = 10;
int main()
{
foo();
foo();
return 0;
}

int foo()
{
static int k= 1;
printf("%d ",k);
k++;
return 0;
}

What is the output of the above code snippet?

  1. $2,3$
  2. $1,2$
  3. $1,3$
  4. $2,4$
in Programming in C edited by
by
209 views

1 Answer

1 vote
1 vote

ans B

1st time foo is called then k=1     pf(1)    k=2

2nd  time foo is called then k=2     pf(2)    k=3

op=1,2

Answer:

Related questions