0
Please help me with C++ code
In my code 3 inputs, but compiler give me only 1 input ( sorry for my English )
4 Réponses
+ 13
Apart from what Maneren said , your code had some errors..
Remember to give all 3 inputs at the beginning on different lines..
eg :
3
2
1
https://code.sololearn.com/cvBhy7CZs7uk/?ref=app
+ 4
Change line 51 to num_1 % num_2
+ 3
In Sololearn you have to give all inputs before actually running the code, so you have to write them to prompt all at once separated by newline
0
#include <iostream>
using namespace std;
int main()
{
//calculator by artpubgm
// only int, without double, float, etc.
int num_1; // 1st input
int num_2; // 2nd input
int type; // 1 = + ; 2 = - ; 3 = *; 4 = /; 5 = %;
// 3rd input
{
cin>>num_1>>num_2>>type; // ERROR: Compiler make only one input
/* cin>>num_1;
cin>>type;
cin>>num_2; */ // not use.
}
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;
if ( type == 0 )
cout << "Error" << endl;
else if ( type > 5 )
cout << "Error" << endl;
}
// cout << num_1 << type << num_2 << endl;