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?

26th Nov 2019, 7:07 PM
kazem jalili
kazem jalili - avatar
11 odpowiedzi
26th Nov 2019, 9:12 PM
NightFox
NightFox - avatar
+ 1
|| is “or” operator. One of the statements needs to be true.
27th Nov 2019, 3:36 PM
varFildom_
varFildom_ - avatar
+ 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.
28th Nov 2019, 5:01 AM
Nemo
+ 1
Monical || checks if one of the operators are true.
28th Nov 2019, 3:39 PM
Justinas Kimtys
Justinas Kimtys - avatar
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!’) }
26th Nov 2019, 10:25 PM
Logomonic Learning
Logomonic Learning - avatar
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.
27th Nov 2019, 4:32 AM
LunarCoffee
LunarCoffee - avatar
0
|| is a or operator. Which returns true if any one of two statement is true.
28th Nov 2019, 11:27 AM
Eshant Aggarwal
Eshant Aggarwal - avatar
- 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)
26th Nov 2019, 7:11 PM
Ipang
- 1
That means "OR" or you can consider them as wall between if statements which divide them.
28th Nov 2019, 5:59 PM
CoderBittu
CoderBittu - avatar
- 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" }
28th Nov 2019, 6:05 PM
CoderBittu
CoderBittu - avatar