+ 5

the or operator

using the or operator is same as the else !!!!!!

19th Apr 2019, 10:33 AM
Idris Abdellah
Idris Abdellah - avatar
4 ответов
+ 7
No there diffrent thats why it exists. (a || b){print a} if either a or b is true then the block is exectued but once inside here it dosent know which one was true resulting in a always being printed. If(a){print a} else {print b} this keeps them apart and has a diffrent output each statment knowing what to output
19th Apr 2019, 11:19 AM
D_Stark
D_Stark - avatar
+ 5
Or operator work in when you have to check 2 or more condition at the same time and from all condition if any of the condition is true then all the condition will be true or operator work as follows let A and B be two condition which is to be checked now A B AorB T T T T F T F T T FF F you can also understand it like let T=1 F=0 if you add 1, 1 you get 1 in boolean and that is true again add 1 ,0 you get 1 and that is true and so on... so you can also understand like this...
22nd Apr 2019, 8:02 AM
Md Shadab Alam
Md Shadab Alam - avatar
+ 2
They are similar in some situations. Python: print(a or b) is the same as: if a: print(a) elif b: print(b) else: print(False) I can't think of something similar in C++ though. /Edit: I think I can see where you're coming from. if(a || b) is true if a is true. Else (if a isn't true) it's true if b is true. I'm not sure if this helps understand how boolean logic works though
19th Apr 2019, 11:06 AM
Anna
Anna - avatar
+ 2
Thank u all for your answer Its work if any condition is true 😁
19th Apr 2019, 2:07 PM
Idris Abdellah
Idris Abdellah - avatar