0
Help me with C++ error
5 Answers
+ 6
Look at my annotations
https://code.sololearn.com/c46LadPhK8Ky/?ref=app
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;
}
0
This code always output 32765
0
P. S. It's calculator
0
Thanks



