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

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;
int answer = 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')
{
answer = num1 + num2;
cout <<"Sum: " << answer << endl;;

}

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

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

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

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

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

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

would someone please help me debug this program to find the problem? Thank you, Diana

• I am facing some problems with this code..Any suggestion..

[url=http://homeremedieslog.com/baby-constipation]Baby Constipation[/url]
• If you want there to just be the answer displayed enter:

cout <<"" << answer << endl;

Your code contained "Sum: ", this is why it was giving you thas output.
• Also, there is still a problem with your code, it always adds, it never subtracts, multiplies or divides.

Hint: look at your logical operators.