Not the results I am looking for ** HELP ** - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Not the results I am looking for ** HELP **

Posts: 2Member
Ok, I have got my program working but it is displaying to many results. It is displaying the answer behind of the word Sum
. If I input 'M' then the answer is still displaying behind the word Sum
. Same thing for 'S' (for subtract) and 'D' (divide). Here is my code:

//This program will add, subtract, multiply or divide depending on what the user inputs

#include

using namespace std;

int main()
{
char operation = ' ';
int num1 = 0;
int num2 = 0;

cout <<"Enter A (add) or S (subtract) or M (multiply) or D (divide): ";
cin >> operation;
operation = toupper(operation);

if (operation != 'A' && operation != 'S' && operation != 'S' && operation != 'M' && operation != 'D')

{
cout <<"Error: Wrong letter entered" << endl;
return 0;
}

cout <<"Enter first number: ";
cin >> num1;
cout <<"Enter second number: ";
cin >> num2;

if (operation == 'A' || 'a')
{
cout <<"Sum: " << answer << endl;;

}

else if (operation == 'S' || 's')
{
if (num1 > num2)
{
}
else

cout <<"Difference: " << answer << endl;
}

else if (operation == 'M' || 'm')
{
cout <<"Product: " << answer << endl;
}

else if (operation == 'D' || 'd')
{
if (num1 > num2)
{
}
else

cout <<"Quotient: " << answer << endl;
}

system("pause");
return 0;
}//end of main function

• Posts: 1Member
I am facing some problems with this code..Any suggestion..