New course! Every coder should learn Generative AI!
Try a free lesson0
Adarsh Naidu
Explanation:
In case of
d= ++a && ++b || ++c;
So first the a value gets incremented to 6 and the b value gets incremented to -6.
Here the logical and operator performs its action
The ‘&&’ operator returns true when both the conditions in consideration are satisfied. Otherwise it returns false.
It means as 6 && -6 it is true ,so the value is 1
so the and operation over here..
So to understand it well first know how logical or works.
The ‘||’ operator returns true when one (or both) of the conditions in consideration is satisfied. Otherwise it returns false. For example, a || b returns true if one of a or b is true (i.e. non-zero). Of course, it returns true when both a and b are true.
If any of the condition is true automatically the true value is 1
In case of false it is zero..
So the logical and operator that is 6 && -6 it becomes true and the value is 1.
If anyone of the side is true in or operator then everything is true and the d value becomes 1 and the incre