hi, can you guys help me out with this portion of code. I don't know what's wrong with it.
Code:
#include <stdio.h>
#include <math.h>
main()
{
int count;
float ctr,a;
char x,s,S,c,C,q,Q;
do{
printf("(S)ine, (C)osine, or (Q)uit: ");
scanf("%c", &x);
if(x!='s' && x!='S' && x!='c' && x!='C' && x!='q' && x!='Q')
printf(" -- Illegal Input!\n");
} while(x!='s' && x!='S' && x!='c' && x!='C' && x!='q' && x!='Q');
}
it is supposed to print out this:
Code:
(S)ine, (C)osine, or (Q)uit: x
-- Illegal Input!
(S)ine, (C)osine, or (Q)uit:
but it prints this out:
Code:
(S)ine, (C)osine, or (Q)uit: x
-- Illegal Input!
(S)ine, (C)osine, or (Q)uit: -- Illegal Input!
(S)ine, (C)osine, or (Q)uit:
it prints out an extra line of sine, cosine, or quit with the illegal input statement after that. What did i do wrong? Help!!