Wednesday, October 29, 2008

What will happen when the program below is compiled and executed?

int i;
int increment( int *i )
{
return ++i;
}

int main()
{
  for( i = 0; i < 10; increment(i) ) 
   {} 

   printf("i=%d", i); 
 return 0;


Choice a: It will not compile
Choice b: It will print out i=9 
Choice c: It will print out i=10 
Choice d: It will print out i=11
Choice e: It will loop indefinitely

No comments: