Совсем недавно начал изучать с++ , пока читал подумал, что уже могу сделать калькулятор. Но что то пошло не так. Я подозреваю что ошибка ну очень глупая, сам по незнанию найти не могу. Почему код не работает так, как следует, а всегда выполняется деление двух чисел?
#include <iostream>
using namespace std;
int main()
{
int x, a, b;
int c;
cout << "Press the number" << endl ;
cin >> a;
cout << "Press another number" << endl ;
cin >> b;
cout << "Press 1 , if you need to add two numbers." << endl ;
cout << "Press 2 if it is necessary to subtract one number from another." << endl ;
cout << "Press 3 if you multiply 2 numbers. Press 4 if it is necessary to divide one number by another." << endl ;
cout << " Press any number other than these if you do not know English." << endl ;
cin >> x;
if (x = 1)
c = a + b ;
if (x = 2)
c = a - b;
if (x = 3)
c = a * b;
if (x = 4)
c = a / b;
if (x > 4)
cout << "Learn English" ;
cout << "Result is" << endl << c;
return 0;
}
Сборка персонального компьютера от Artline: умный выбор для современных пользователей