Code:
int i=3;
switch(i)
{
   default:
      printf("zero");
      break;
   case 1:
      printf("one");
      break;
   case 2:
      printf("two");
      break;
   case 3:
      printf("three");
      break;
}
the result obtained for this code is three.. what is the reason..

i think zero might be the result since the default statement comes before the other case statement.. so a soon as it enters the switch it might execute the statements within default and exit the switch on seeing the break statement ... therefore zero will be the output... but it is not why...?????

what happens exactly during the execution????
help me friends!!

Last edited by shabbir; 12Aug2007 at 06:25.. Reason: Code block - http://www.go4expert.com/forums/misc.php?do=bbcode#code