My question is how I ask the user if he/she wants to input again. ex. do you want to calculate again? yes or no.
Can someone explain what I am doing wrong and fix the error.
int main() {
}
int a;
cout << endl << "Write 1 for addition and 0 for substraction:" << endl;
cin >> a;
// addition
if (a == 1) {
cout << "You are now about to add two number together, ";
cout << "enter a number: " << endl;
int b;
cin >> b;
cout << "one more: " << endl;
int c;
cin >> c;
cout << b + c;
}
//Substraction
else if (a == 0) {
cout << "enter a number: " << endl;
int b;
cin >> b;
cout << "one more: " << endl;
int c;
cin >> c;
cout << b - c;
}
//If not 1 or 0 was called
else {
cout << "Text" << endl;
}
return 0;
}
Important things to note:
<string>
to use strings.Simplified Calculation Code
This code should be inside the
do ... while
loop.