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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top