Compilation error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Compilation error

Guys I have written this code for a simple calculator but the compiler is showing “compilation error”. Please correct my code if i had made a mistake and also help with this loop command if I can add in this code. I shall be very thankful to you #include <iostream> using namespace std; int main() { int a; cout<<"enter value"; cin>>a; int b; cout<<"enter second value"; cin>>b; int value; cout<<"Choose 1 for sum"<<endl;"choose 2 for sub"<<endl;"choose 3 for mul"<<endl;"choose 4 for div"<<endl;"choose 5 for rem"<<endl; cin>>value; switch(value){ case 1: sum=a+b; cout<<"sum is"<<sum<<endl; break; case 2: sub=a-b; cout<<"sub is"<<sub<<endl; break; case 3: mul=a*b; cout<<"mul is"<<mul<<endl; break; case 4: div=a/b; cout<<"div is"<<div<<endl; break; case 5: rem=a%b; cout<<remainder is<<rem<<endl; break; } return 0; }

30th May 2018, 12:10 AM
Fahadiqbal
2 Answers
+ 4
In your cout after "int value;", replace all those semicolons with <<. Ex: cout << "Choose 1 for sum" << endl << "Choose 2 for difference" << endl << "Choose 3..." << endl;
30th May 2018, 1:00 AM
Tamra
Tamra - avatar
+ 1
thanks alot!!
30th May 2018, 1:42 PM
Fahadiqbal