+ 13
Do Conditional Operators have precedence?
i come across a question in submissions about these operator's != , || , && having precedence in java. i know that maths operators do but i have never heard of conditional operator's having them before? i choose false but apparently i was wrong?
13 Respostas
+ 23
yes
/*i submitted a good quiz on that but was declined saying "so many quizzes of this type already exist" đ*/
+ 23
yaa we have that type of quiz in C++
guess what I just played ...đđđ
cout<<!(1||0&&!1)
//output :- 0
+ 19
true||false&&false
//answer will be true , but most ppl do it as false đ
//so i made this as quiz
+ 17
it will be treated as true||(false&&false) ..... true||false ... ie true
//bcz precedence of && is greater than that of ||
@David
+ 10
@Cool Coding Thank you very much! i do wonder though why i have only just learned this now. đ€
+ 10
@ Gaurav did you make code quiz about it? if so can i have a look at it ? đ
+ 8
Thank you very much Gaurav thats perfect đđđđ
+ 7
@ Gaurav can you explain to me how i should read true||false&&false i have never seen this before whats going on with me haha đš thanks
+ 7
đ€ now im unsure what answer is right is there anyway to see step by step execution of this exspression? thanks
+ 2
true||false&&false..... The answer is false.
The checking starts from left to right and not according to precedence.
While checking from left to right the execution takes place in this way.... đ
(true||false)&&false
true&&false
false
I took help of parentheses just to explain you... Thank you.