#include <iostream>
using namespace std;
int main()
{
int choose, num1, num2, result1, result2;
cout << "Type '1' for plus, '2' for minus\n";
cin >> choose;
if (choose = 1) {
cout << "Enter the first number :\n";
cin >> num1;
cout << "Enter the second number :\n";
cin >> num2;
cout << "Here's the result :\n";
result1 = num1 + num2;
cout << result1;
}
if (choose = 2) {
cout << "Enter the first number :\n";
cin >> num1;
cout << "Enter the second number :\n";
cin >> num2;
cout << "Here's the result :\n";
result2 = num1 + num2;
cout << result2;
}
while (choose != 1 || 2) {
cout << "You need to type '1' or '2'!\n";
cin >> choose;
if (choose = 1) {
cout << "Enter the first number :\n";
cin >> num1;
cout << "Enter the second number :\n";
cin >> num2;
cout << "Here's the result :\n";
result1 = num1 + num2;
cout << result1;
}
if (choose = 2) {
cout << "Enter the first number :\n";
cin >> num1;
cout << "Enter the second number :\n";
cin >> num2;
cout << "Here's the result :\n";
result1 = num1 + num2;
cout << result2;
}
}
}
so i'm trying to create a simple calculator by typing 1 for "+" or 2 for "-" but doesn't seems to work, i use "while" so when you type other value it will ask you to type 1 or 2, but when i debug it, it always executed (the "while") even if i type 1 or 2, please help me.