Logical operators doubt

Can we use logical operators between three conditions to be checked simultaneously?

Hi @dktrip,
No you cannot compare simultaneously. When we use one logical operator to compare two value then we get a boolean result and it cannot be further compared with third value . For example if a=5, b =5 , c= 5 and we use logical operator (a==b==c) then this will first compare a==b and return true and then it will compare the returned result ‘TRUE’ == c which will give incompatiible types error as one is boolean and the other is a int.

Then could you just suggest of some method to compare three conditions simulataneously because if i use lopps i mean nested loops then my time complexity increases.

Like if you want to compare a and b and c then you will have to compare a with b and then b with c.Like for equality you can do if a==b and then b==c . there is no other way .If the complexity is more than there will be other way to solve . Compare alone will not have such great effect on complexity. And rather than using loop use if and else twice for three checks . Please send code or the case in which you are trying to apply.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.