0

Is there another code instead of codes ( if and switch...case) and do the same operation of if and switch?

16th Nov 2016, 8:19 PM
Ehsan Yashar
Ehsan Yashar - avatar
3 ответов
+ 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;
16th Nov 2016, 8:40 PM
Tamra
Tamra - avatar
+ 3
no
16th Nov 2016, 8:25 PM
NICKALL [EP]
NICKALL [EP] - avatar
+ 2
n0
16th Nov 2016, 8:38 PM
Yash Kumar
Yash Kumar - avatar