Alright so i have this code i made, and i want to ask if you are sure that is what you want but i dont know how. here is the code. ill bold the part i need help in
// Michael DeGray Wednsday September 23, 2009
#include <iostream>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
int main()
{
int numb1;
int numb2;
int numb3;
int numb4;
int sum1;
int sum2;
char Y;
char N;
cout << "This program will take two numbers and add them, then it will take two seperate number add them and compaire the two. " << endl << "\nPlease input your first number.\n"; // promts for user input
cin >> numb1; // stores inputed number as numb1
cout << "Please input the number to be added to the previous number.\n"; // promts for user input
cin >> numb2; // stores inputed number as numb2
cout << "The first equation is " << numb1 << " + " << numb2 << endl << "Is this correct? Y/N\n"; // shows the equation for the first set of inputed numbers
cin >> Y;
if Y
sum1 = ((numb1 + numb2));
cout << "The answer to the first equation is " << sum1 << endl; // shows answer to first equation
cout << endl << "Please input the first number of the second equation.\n"; // asks for user input
cin >> numb3; // stores inputed number as numb3
cout << "Please input the number to be added to the previous number.\n"; // asks for user input
cin >> numb4; // stores inputed number as numb4
cout << "The second equation is " << numb3 << " + " << numb4 << endl; // shows equation for the second set of inputed numbers
sum2 = ((numb3 + numb4));
cout << "The answer to the second equation is " << sum2 << endl << endl; // shows answer to second quation
if ( sum1 == sum2 ) // Is the two numbers are equal display the following
cout << sum1 << " == " << sum2 << endl;
if ( sum1 != sum2 ) // if the two numbers are not equal display the following
cout << sum1 << " != " << sum2 << endl;
Now if the user types Y then it contuines with the program but if they press N it will ask them for 2 numbers again. how would i do this? thanks in advance
EDIT: for some spelling errors (there are probably more i missed but i think it's readable)
didn't quite get you when you said continue with program ...how should the program look?
btw the if statement should have something like if (y) ...parenthesis are required..
1) You don't need to include the whole std namespace when you're including some parts of it.
2) A variable name has nothing to do with user input. You're storing the user input in a variable of type char with the name "Y" and assumes the user really typed Y. But the user can also type in other things.
You could use a char variable, then check what the user did input. You will need to use a while loop to ask for 2 numbers again. To use yes/no, you will need a boolean variable.