C quiz questions/answers?

Rob Wehrli plug-devel@lists.PLUG.phoenix.az.us
Mon Nov 5 15:26:02 2001


I've been writing an C "test" and thought that I'd ask the list for any
good traps/questions they might have...but not without at least offering
one.

#include <stdio.h>

int main( int argc, char * argv[] )
{
  int x = 100;
  int i = 102;

  i < 100 ? x = i : x = 100;

  printf( "x = %d\n", x );

  return 0;
}


What is the output of the following program:


A: Does not compile, does not execute.
B: x = 100
C: x = 102
D: None of the above

IF A or D, explain your answer:

____________________________________________

____________________________________________

____________________________________________

____________________________________________



(No fair cheating and using a computer!)


Take Care.

Rob!