Why cant I use variable!=+ or variable!=- in C for example [closed]

In your code, I see the following statement:

scanf("%c", &choice);

So I am judging that the type of the variable ‘choice’ is char.

For character comparison, you need to use a single quote, not double quotes. So replace the

if (choice!="+"&&choice!="-"&&choice!="*"&&choice!="https://stackoverflow.com/");


if (choice!='+'&&choice!='-'&&choice!='*'&&choice!="https://stackoverflow.com/")

Also, remove the semicolon from the end of the if statement. It doesn’t make sense.

Leave a Comment