Wednesday, February 3, 2010

tricky question on switch-case

#include
int main()
{
int a=10;
switch(a)
{
case '1': // even if a=1 this case doest not work because it is checking for char '1';
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut:
printf("NONE\n");
}
return 0;
}

The above program compiles with out any error, but when you run it, it does not give any output

The reason is spelling of key word default is wrong.

1 comment:

HARI said...

I think its not a tricky Question man.....and its not as tough as u mentioned....