+ 7
How to do that
I want to compare something like char or string with another for example the operators can I abbreviate this expression if (op=='+'||op=='-'||op=='*'||op=='/'){do something} to be like if(op=x){do something}
4 Respostas
+ 3
the point is that I want to abbreviate like
char a= 'a'||'b'||'c';
if(op==a);
+ 2
maybe its better to use the switch?
if(po=='+'){
do ...
} else if (po=='-'){
do ...
} else if (po='*'){
do ...
} else if (po=='/'){
do ...
}
+ 1
Do you mean that if one condition is true, do something?
if (op = 'a' || op = 'b' || op = 'c') {
do...
}