&& operator

as far as in know,if the left hand side of && evaluates false then the right handside of it doesnt get evaluated,then how cum j is incremented to 3?
1
2
3
4
5
6
7
#include <stdio.h>
int main()
{
    int i=-3,j=2,k=0,m;
    m=++i&&++j||++k;
    printf("%d%d%d%d",i,j,k,m);
}
Because -2 evaluates to true, any non zero number will be true when converted to bool.
priority of the && operator is more than that of || then in this statement m=++i||++j&&++k++i should not be incremented according to me
|| and && work Left-To-Right, short-circuiting (the fancy name for only having one side of the expression evaluate) will never (AFAIK) prevent the left hand side from evaluating, it will only prevent the right hand side. Putting m=++j&&++k||++i; illustrates this.
thnx alot :)
Topic archived. No new replies allowed.