0

Logical operating with And

Can anyone explain how, (10<5) and ((5/0)<10) if False but, (10>5) and ((5/0)<10) is error?

8th Aug 2020, 5:37 PM
Ree
6 Antworten
0
In conditional operation of && For A && B, (A, B are individual expressions) If A operation return false then it won't execute B expression. Because 0&&0 = 0 0&&1 = 0 so there is no need to execute B. If A returns true, then going to execute B for its boolean value.. So in your first case 10<5 is false, so here it stop evaluation and return false. In 2nd test: 10>5 is true so must evaluate 5/0 <10 also but 5/0 is run time error.. Note that 5/0 is run time error not compile time error so it won't be error until is is executed.. Hope it helps...
8th Aug 2020, 7:46 PM
Jayakrishna 🇮🇳
+ 2
you cant divide by zero
8th Aug 2020, 5:40 PM
Slick
Slick - avatar
+ 1
it looks like the first is False because its fully false. 10 isnt less than 5 and zero div err comes out to False as well. (i guess) In the 2nd, 10 is greater than 5. Causing that half to be True, making the second statement not fully False. giving you an error
8th Aug 2020, 6:12 PM
Slick
Slick - avatar
+ 1
Thank you guys for your answers. And yes Slick, I ran a few tests and came up with the same hypothesis mentioned by Jayakrishna. Thank you to both of you for helping me out. Cheers.
8th Aug 2020, 8:46 PM
Ree
0
Then how can the first expression (10<5) and ((5/0)<10) be false? And the second expression be error?
8th Aug 2020, 6:04 PM
Ree
0
Just do a bunch of tests on it and come up with your own hypothesis if that doesnt satisfy.
8th Aug 2020, 6:13 PM
Slick
Slick - avatar