The output is
0 0 1 3 1
This is as follows
First the expression gets reduced as
m = -1 && -1 && 0 || 2
This is because ++ gets the higher precedence and being postfix operator it is first applied to expression and then only incremented. Now in this Logical AND gets higher precedence over Logical OR and the associativity or the order in which Logical AND as well as Logical OR gets executed is left to right
So -1 && -1 && 0 gives result as 0
This Logical OR with 2 namely m = 0 || 2 gives value as 1
So value of m is 1.
Now the expression is evaluated so the variables i, j, k, l gets incremented and all gets printed resulting in output as
0 0 1 3 1
What is the output of the following program?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); }
The output is
0 0 1 3 1
This is as follows
First the expression gets reduced as
m = -1 && -1 && 0 || 2
This is because ++ gets the higher precedence and being postfix operator it is first applied to expression and then only incremented. Now in this Logical AND gets higher precedence over Logical OR and the associativity or the order in which Logical AND as well as Logical OR gets executed is left to right
So -1 && -1 && 0 gives result as 0
This Logical OR with 2 namely m = 0 || 2 gives value as 1
So value of m is 1.
Now the expression is evaluated so the variables i, j, k, l gets incremented and all gets printed resulting in output as
0 0 1 3 1
Profile Answers by GeekAdmin Questions by GeekAdmin
Questions by GeekAdmin answers by GeekAdmin
Related Answered Questions
Related Open Questions