why does this prg does not display "NONE"

S

sunny

int a=10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut:
printf("NONE\n");
}
 
P

Preben Traerup

sunny said:
int a=10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut:
printf("NONE\n");
}
propably because a does not have value defalut :)
../Preben
 
R

ramasubramanian.rahul

check the spelling of default ... and dont waste others time with such
hopeless questions
 
Z

zorigaman

sunny a écrit :
int a=10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
default:
printf("NONE\n");
}

Because it seems that with the quotes, you're evalutating the character
(ascii code), not the value itself.
Try :
 
C

Clever Monkey

sunny said:
int a=10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut:
printf("NONE\n");
}
Why do people continue to post this lame snippet?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top