What happens if i put && and || together.? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What happens if i put && and || together.?

for example see this code: if (a>b || a==b && b>c) so how does it interpret it.... so will it be true when either a>b or a= b along with b being greater than c.... or will it be true either if only a>b or if both a=b and b>c??? or can i use parenthesis to group them???

9th Mar 2016, 11:01 AM
Sayan Ghosh
Sayan Ghosh - avatar
2 Answers
+ 1
Google c++ operators precendence. If you don't know which ones have higher precendence you can just use parentheses. a > b || a == b && b > c would be interpreted as: (a > b) || ((a == b) && (b > c))
2nd Apr 2016, 9:36 AM
Przeszczep
- 2
it just depend on the input you give for the respective variable...for example, if you assign value of 20 to variable 'a', 15 to 'b' & 10 to 'c', then the output will be a>b & b>c.
18th Mar 2016, 4:16 AM
Riya
Riya - avatar