+ 1
Why isn't it working
#include <iostream> using namespace std; int main() { string a int b,c; cin>>a; cin>>b; cin>>c;} if(a=add){ cout<<a+b; } if(a=multiply){ cout<<a*b; } return 0; }
3 Answers
+ 7
#include <iostream>
using namespace std;
int main() {
string a
int b,c;
cin>>a;
cin>>b;
cin>>c;
if(a=="add"){
cout<<b+c;
}
if(a=="multiply"){
cout<<b*c;
}
return 0;
}
Vikram
+ 3
string a; //you forgot a semicolon
cin >> c; //no '}'
if (a=="add" ) {
//= means assignment in C++. You are trying to give a the value add. == is the equality comparison. Moreover a == add checks to see wether the variable a has the same value as the variable add. "add", with quotation marks, refers to the value itself.
if (a=="multiply") {
+ 1
thank you sir