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?
6 Réponses
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...
+ 2
you cant divide by zero
+ 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
+ 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.
0
Then how can the first expression (10<5) and ((5/0)<10) be false? And the second expression be error?
0
Just do a bunch of tests on it and come up with your own hypothesis if that doesnt satisfy.