0

When I wrote this code it run successfully but the output was not right please some one help me.

https://code.sololearn.com/c4Pp6X9Ngq0e/?ref=app

23rd Feb 2020, 11:05 AM
Hussain Ali
Hussain Ali - avatar
5 Réponses
0
https://code.sololearn.com/c4Pp6X9Ngq0e/?ref=app
23rd Feb 2020, 11:11 AM
Hussain Ali
Hussain Ali - avatar
0
Cin >> d; You have to put your input in onother char variable to compare with chr d[] not put your input in d[]. #include <iostream> using namespace std; int main(){ double a,b,c; char d[5]={'+','-','*','/','%'}; char op; cout<<"Please enter the number \t"; cin>>a; cout<<"what you want to do \t "; cin>>op; cout<<"Provide the 2nd Value \t"; cin>>b; if(op == d[0]) c=a+b; if(op == d[1]) c=a-b; if(op == d[2]) c=a*b; if(op == d[3]) c=a/b; if(op == d[4]) c=a/b*100; cout<<endl<<"Your result is: "<<c; return 0; }
23rd Feb 2020, 11:17 AM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar
0
Thanks man I got the idea now
23rd Feb 2020, 11:24 AM
Hussain Ali
Hussain Ali - avatar
0
U r welcome.
23rd Feb 2020, 11:26 AM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar