Trouble with program

I am writing a program where a person needs to choose between whethere they want two integers they have input to be output as a sum quotient product or difference, but when i enter the two integers it just shows all of the possible results rather than recognizing the users choice in terms of which operation they want to use.

#include <iostream>
using namespace std;

int main ()
{
int num1, num2, sum, difference, product, quotient, S, D, P, Q, remainder;

cout << "Enter two intergers: ";
cin >> num1;
cin >> num2;

cout << "(S)um " << endl;
cout << "(D)ifference " << endl;
cout << "(P)roduct " << endl;
cout << "(Q)uotient " << endl;

sum= num1 + num2;

S= sum;

difference= num1 - num2;

D=difference;

product= num1 * num2;

P=product;

quotient= num1 / num2;

Q=quotient;

remainder= num1 % num2;

cout << "Please choose S, D, P, or Q: ";
cin >> S;
cin >> D;
cin >> P;
cin >> Q;

if (S)
cout << num1 << " plus " << num2 << " is " << sum << endl;
{
else if (D);
cout << num1 << " minus " << num2 << " is " << difference << endl;
}
{
if (P)
cout << num1 << " times " << num2 << " is " << product << endl;
}
{
else if (Q);
cout << num1 << " divided by " << num2 << " is " << quotient << " with a remainder of " << remainder << endl;
}


return 0;
}
Instead of this:
1
2
3
4
5
cout << "Please choose S, D, P, or Q: ";
cin >> S;
cin >> D;
cin >> P;
cin >> Q;


Try something like this:
1
2
3
4
5
6
7
8
9
char choice; // can only take one character, i.e 1 letter
cout << "Please choose S, D, P, or Q: ";

cin >> choice;

if( choice == 'S' )
    // code...

...
cout << "Please choose S, D, P, or Q: ";
cin >> S,D,P,Q


if (S=S)
cout << num1 << " plus " << num2 << " is " << sum << endl;

else if (D=D);
cout << num1 << " minus " << num2 << " is " << difference << endl;

else if (P=P)
cout << num1 << " times " << num2 << " is " << product << endl;

else if (Q=Q);
cout << num1 << " divided by " << num2 << " is " << quotient << " with a remainder of " << remainder << endl;

http://imageshack.us/photo/my-images/832/programsw.jpg/

I need it to only show whether it is the sum, or difference. not all of them at once
Topic archived. No new replies allowed.