0
what || means?
i have a problem to solve pop quiz which is in the course. i think that || means either a or b is correct but it shows me neither a nor b is correct. I'm not native in English, what is the difference between these two statement?
11 Respostas
+ 6
https://stackoverflow.com/questions/5666741/what-exactly-does-mean
Read this, it might be helpful
+ 1
|| is “or” operator. One of the statements needs to be true.
+ 1
bool operator||(bool arg1, bool arg2)
{
if (arg1)
return true;
if (arg2)
return true;
return false;
}
Any input arguments that aren't bool are implicitly converted.
+ 1
Monical || checks if one of the operators are true.
0
it is one of the logical operators meaning or, along with & = and , !=not.
you are likely to see them in if control structures. in addition to relational operators e.g.
if( age<15 || age>80){
print(‘youre not allowed to drive!’)
}
0
a || b doesn't guarantee that either a or b are "correct," it simply tests if they are. What a || b equals (true or false) depends on what a and b are. For example, if a = true and b = false, then a || b would be true since a is true. However, if a = false and b = false, a || b would also be false, since neither a or b are true.
0
|| is a or operator. Which returns true if any one of two statement is true.
- 1
Can you tell me which chapter and what the quiz question was? maybe I can have a review on it.
Is that quiz in the following chapter? I would suggest you to review the lesson, and check out in lesson comments. A lot of people discuss lesson topic in detail there 👍
https://www.sololearn.com/learn/CPlusPlus/1619/
(Edited)
- 1
That means "OR" or you can consider them as wall between if statements which divide them.
- 1
If (a==1){
cout<<"Hi";
}else if (b==1){
cout<<"Hi";
}
Same as
If(a==1 || b==1){
cout<<"Hi";
}
if we convert this code to human word then -
if a is equal to 1 or b is equal to 1 then cout "Hi"
this can be used for a single variable too but the condition values must be different just like
if a is equal to 1 or if a is equal to 2 then cout "Hi"
if(a==1 || a==2){
cout<<"Hi"
}