Here are few outputs i got:Code:#include<iostream> int main() { using namespace std; cout<<"\nEnter first num:"; double a,b; cin>>a; cout<<"\nEnter second number:"; cin>>b; char ch; cout<<"\nChoose one:\n+,-,*,/"; cin>>ch; if(ch=='+') { cout<<endl<<a+b; cin.get(); } if(ch=='-') { cout<<endl<<a-b; cin.get(); } if(ch='*') { cout<<endl<<a*b; cin.get(); } if(ch='/') { cout<<endl<<(a/b); cin.get(); } cin.get(); return 0; }
First:
second:Code:Enter First num:8 Enter second number:6 choose one: +,-,*,/ + 14 48 1.33333
Third:Code:Enter First num:78 Enter second number:5 choose one: +,-,*,/ - 73 390 15.6
Fourth:Code:Enter First num:54 Enter second number:25 choose one: +,-,*,/ * 1350 2.16
I included cin.get() in all the four if blocks bcoz the window was shutting down automatically.Code:Enter First num:7 Enter second number:3 choose one: +,-,*,/ / 21 2.33333
I am using Dev c++
Thanks!!



LinkBack URL
About LinkBacks


