0
Is there another code instead of codes ( if and switch...case) and do the same operation of if and switch?
3 Respostas
+ 8
There is the Ternary Operator, that serves as shorthand for a single if/else.
It works like this:
condition ? codeIfTrue : codeIfFalse
Which is the same as:
if(condition)
codeIfTrue
else
codeIfFalse
Here's an example:
cout << num % 2 == 0 : "Even" : "Odd" << endl;
+ 3
no
+ 2
n0