edited by
221 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$
edited by

1 Answer

1 votes
1 votes

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

3 votes
3 votes
1 answer
1
Bikram asked May 14, 2017
420 views
Assume that $a[4]$ is a one-dimensional array of $4$ elements, $p$ is a pointer variable and $p = a$ is performed. Now, which among these expressions is illegal?$p == a[0...
0 votes
0 votes
1 answer
2
Bikram asked May 14, 2017
364 views
Spot the error(s) in this code snippet :int n=2; // Line 1 switch(n) { case 1.5: printf( "gate"); break; case 2: printf( "overflow"); break; case 'A': printf("gateoverflo...
0 votes
0 votes
1 answer
3
Bikram asked May 14, 2017
220 views
What is the output of the following program? int fun (int z) { if( z==0 || z==1 ) return 1; else return fun(z-1) ; } int main() { int y; y=fun(8); printf(“%d”...
2 votes
2 votes
1 answer
4
Bikram asked May 14, 2017
753 views
What is the output of the below mentioned code snippet?#include <stdio.h int main() { int i=10; static int x=i; if(x==i) printf("Equal"); else if(x>i) printf("Greater"); ...