Why is a=4 evaluated as true but b=0 evaluated as false in an if condition?

In both C and C++ language, any non-zero value is treated as true. In if condition you are assigning 4 and 0 to a and b causing the value of expressions a = 4 and b = 0 to be 4 and 0 respectively.

Leave a Comment