A
Anjali M
#include<stdio.h>
int main()
{
int a = 10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut:
printf("NONE\n");
}
return 0;
}
If you think, this will print NONE, look carefully. The 'default' is
misspelled. I compiled this on gcc-2.95. Why doesnt the compiler
complain that this program is faulty? Why does it accept this program
as a valid one?
Thanks in advance,
Anjali.
int main()
{
int a = 10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut:
printf("NONE\n");
}
return 0;
}
If you think, this will print NONE, look carefully. The 'default' is
misspelled. I compiled this on gcc-2.95. Why doesnt the compiler
complain that this program is faulty? Why does it accept this program
as a valid one?
Thanks in advance,
Anjali.