enum fivenums {Z,O,T,TH,F,FI}
int main()
{
char ch;
int num;
do{
scanf("%d",&num);
switch(num)
{
case Z:
printf("ZERO\n");
break;
case O:
printf("ONE\n");
break;
case T:
printf("TWO\n");
break;
case TH:
printf("THREE\n");
break;
case F:
printf("FOUR\n");
break;
case FI:
printf("FIVE\n");
break;
default :
printf("Invalid\n");
break;
}
getchar();// to eat '\n' terminator so that it waits for below
}
while ((ch =getchar())=='\n');
return 0;
}
in the above program if i input a number between 0 -3 its working fine.
but if the input is any alphabet i am getting a different out put;
for example:
my input is
1
o/p: ONE
2
o/p: TWO
and if its
a O/P is:
TWO
if i give a its giving the previously read input as out put
i.e 2.
and for any other alphabets also its giving the same o/p.
why is it giving the previous one.
when its already read from the buffer.