18th Oct 2019, 4:35 AM
Dinesh S
Dinesh S - avatar
3 Answers
+ 2
The boolean operator || checks if one or both statements are true, what it does is that if the first statement is true it doesn't even bother to check the other one because if one is true then it returns true. So it increments x and x is true (idk why it's true I don't know C++ but the operator acts the same in Java) and it doesnt bother to check the other operators, hence why y and z isn't incremented. It then prints out x x y and z.
18th Oct 2019, 5:29 AM
Odyel - avatar
+ 2
AFAIK in C/C++ any non zero integral number is considered as true. They can be used in place of boolean.
18th Oct 2019, 10:45 AM
19th Oct 2019, 4:33 PM
Mayank Singh
Mayank Singh - avatar