Instructor
Ashish Thakur Replied on 24/07/2019
& will check both the conditions even if the first one is false. Whereas,
&& will not check the second condition of the first one is false
If & will check both the conditions than what will be the output if first condition is true and second is flase.
and if the output will be false than what is the purpose of using it over && operator.
Instructor
Ashish Thakur Replied on 12/07/2020
(1==2) & (1==1) -> out put is false. Both conditions are evaluated
(1==1) & (3==3) -> out put is true. Both conditions are evaluated
(1==2) && (1==1) -> out put is false. Both conditions are evaluated
(1==2) && (3==3) -> out put is true. 1==2 is false. So it does not goes to 3==3 since one condition is false.. result will obviously be false
I believw it should be as folows:
(1==2) & (1==1) -> out put is false. Both conditions are evaluated
(1==1) & (3==3) -> out put is true. Both conditions are evaluated
(1==2) && (1==1) -> out put is false. First(not both) condition is evaluated
(1==2) && (3==3) -> out put is false(not true). 1==2 is false. So it does not goes to 3==3 since one condition is false.. result will obviously be false
Am i right?