0

What's ||?I don't understand about c++:-[

12th Oct 2016, 3:24 PM
Crazy girl
Crazy girl - avatar
4 Answers
+ 5
|| is the logical or operator. The result is true if either operand is true. For example: //returns true if the point (x, y) is on the vertical or horizontal axis bool onAxis(int x, int y) { if ((x == 0) || (y == 0)) { return true; } else { return false; } }
12th Oct 2016, 3:41 PM
Zen
Zen - avatar
0
why don't u refer to ur book?
12th Oct 2016, 3:26 PM
Rahul Prasad
Rahul Prasad - avatar
0
Meaning “or” in contrary to “&&” which means “and”
19th Oct 2016, 2:09 AM
Sai
Sai - avatar
0
|| is a logical operator for 'or'. Ex. you want to eat apple and you have two fruits say x and y. You will say "if either x or y is apple i will eat it." so we can write it in c++ like : if (x=="apple"||y=="apply") {//EAT IT } the code in the braces after if condition will execute if any of the fruit is apple.
24th Oct 2016, 1:49 AM
Yash Raj
Yash Raj - avatar