Sunday, January 10, 2010

#include
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d\n", x, y );
}

int main()
{
func();
func();
return 0;
}

What will the code above print when it is executed?

a) 1 -- 1
1 -- 1
b) 1 -- 1
2 -- 1
c) 1 -- 1
2 -- 2
d) 1 -- 0
1 -- 0
e) 1 -- 1
1 -- 2

No comments: