0

Help me with C++ error

22nd Feb 2019, 7:29 PM
PeaceDeath
PeaceDeath - avatar
5 Answers
22nd Feb 2019, 7:56 PM
Anna
Anna - avatar
0
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int num_1; int num_2; int type; // 1 = + ; 2 = - ; 3 = *; 4 = /; 5 = %; int answer; answer = num_1 + type + num_2; { cin >> num_1; cin >> type; cin >> num_2; } if ( type == 1) { cout << num_1 + num_2 << endl; if ( type == 2 ) { cout << num_1 - num_2 << endl; } if ( type == 3 ) { cout << num_1 * num_2 << endl; } if ( type == 4 ) { cout << num_1 / num_2 << endl; } if ( type == 5 ) { cout << num_2 % num_2 << endl; } else { cout << "Error" << endl; } } cout << answer << endl; return 0; }
22nd Feb 2019, 7:30 PM
PeaceDeath
PeaceDeath - avatar
0
This code always output 32765
22nd Feb 2019, 7:31 PM
PeaceDeath
PeaceDeath - avatar
0
P. S. It's calculator
22nd Feb 2019, 7:31 PM
PeaceDeath
PeaceDeath - avatar
0
Thanks
23rd Feb 2019, 5:25 AM
PeaceDeath
PeaceDeath - avatar