Writing a code for incorrect input

I am new to C++ and have gotten an exercise to do but dont know how to do it.....
Write a program that:
Prompts for:
• The user to type two decimal numbers
• To enter a character (a through d) to choose to add,
subtract, multiply or divide the numbers
Displays:
• The result and the mathematical operation used
• An error message if a wrong character was entered
(Use && operator to check if the character is not between
a and d)

i dont know how to check if the wrong character is entered.

I wrote the following code so far but am getting an error on line 25 dont know why

#include <iostream>

using namespace std;

//Define the main function:
int main()
{
//Declare the variables:
double Num1, Num2;
char Operator;

//User Prompt:
cout << "Please enter the first decimal number and press Enter: ";
cin >> Num1;

cout << "Please enter the second decimal number and press Enter: ";
cin >> Num2;

cout << "Please enter a character (a through d) and press Enter: ";
cin >> Operator;

if Operator != 'a' && != 'b' && != 'c' && != 'd'
cout << "You have entered an incorrect character"

return 0;

}

Please if some1 could help me out..this is the error message I get....

d:\madhurya\humber\semester 10\c ++ programing for automation\programs\exercise 8\exercise 8\exercise 8.cpp(26) : error C2061: syntax error : identifier 'Operator'... Thanx in advance
It's your syntax, you didn't include the parentheses, try:
if (Operator !='a' && Operator !='b' && Operator !='c' && Operator !='d')
{
cout << "Incorrect character" << endl;
return 1;
}
thx it worked....
Topic archived. No new replies allowed.