When we use ||
it will check if first condition is false then it will go to second condition and so on, however the moment it finds a true condition it will return 1.
In this case 4 is true so it will not evaluate further statements here 1 && ++i
and it will directly go to print("%d",i);
As you have initialize i
to 0
it will print the value 0
.
If you want if condition to evaluate 1 && ++i
also, then in place of ||
(OR) use &&
(AND).
1
solved If condition using logical operators