Logical operator in c/c++

main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++l++;
printf(“%d%d%d%d%d”,i,j,k,l,m);
}
Tutorial answer: 00131
Debugging solution:Logical And(&&) operator has the higher priority compare to the Logical or().so first it execute
i++&& j++&k++=-1&&-1&&0=0
then in the logical or operation…l++=02=1.so the value m is 1.finally the value of the other variable is crease by one because increment operator come after the variable.

Post a Comment

0 Comments