+ 7
Conditonal Operator
5 odpowiedzi
+ 2
This behavior is caused by operator precedence rules in C++. conditional operator has higher precedence than , (comma) operator. so the whole conditional statement is interpreted as two statements and not one. Since the condition is true, "hi" is printed twice. The last print "bye" is separated out and will always be executed irrespective of the condition. check my code to understand how the statement is evaluated
+ 4
It's because of operator precedence .
check your updated code ..
https://code.sololearn.com/c2VQ5sIhE2cq/?ref=app
+ 2
https://code.sololearn.com/cfm5vjaguOi1/?ref=app
+ 1
I put the two outputs (with by) after the colon into parentheses ( ) and it worked
+ 1
conditional operator are also known as ternary operator. It acts upon 3 opprents and is represented by ? = Question mark
: = Colon
; = Semi-colon
In conditional operator if condition evaluates true then it will execute the expression after question mark otherwise, it will execute after colon.