Puzzle SL30


What does the following write to the monitor?


/* --- fileA.c --- */
int x = 8;

 
/* --- fileB.c --- */
#include <stdio.h>
 
static int x = 10 ;

void foo( )
{
  printf("x in foo: %d\n", x );
  x = x+10 ;
  printf("x in foo: %d\n", x );
}

void bar( )
{
  printf("x in bar: %d\n", x );
  x = 2*x ;
  printf("x in bar: %d\n", x );
}

 
/* --- fileC.c --- */
#include <stdio.h>
void foo();
void bar();

static int x = 999;

void main()
{
  printf("x in main: %d\n", x );
  foo();
  bar();
  printf("x in main: %d\n", x );
}

What is the output?

How many entities are named x?



Answer         Next Page         Previous Page Home