conditionals QQ
Hello. I was testing conditionals, It work but doesn't work properly. I cant figure out what i did wrong
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <iostream>
using namespace std;
int main (){
int a;
char b;
int c;
char d;
int e;
char f;
int g;
char h;
int i;
char j;
int k;
char l;
cout<<"Please input :\n";
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
cin>>f;
cin>>g;
cin>>h;
cin>>i;
cin>>j;
cin>>k;
cin>>l;
if ((b=d)){
cout<<c<<d<<"\n";
}
else if ((b=f)){
cout<<e<<f<<"\n";
}
else if ((b=h)){
cout<<g<<h<<"\n";
}
else if ((b=j)){
cout<<i<<j<<"\n";
}
else if ((b=l)){
cout<<k<<l<<"\n";
}
else {
cout<<"Error/n";
}
}
|
It doesn't work properly because you are using assignment "=", quotes for clarity, and not comparison "==".
Oh right. Thx
Topic archived. No new replies allowed.