0
What's ||?I don't understand about c++:-[
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;
}
}
0
why don't u refer to ur book?
0
Meaning âorâ in contrary to â&&â which means âandâ
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.