InterviewSolution
Saved Bookmarks
| 1. |
Solve : How does it work?? sequence points??? |
|
Answer» INT i=0; i= ++i + i++ + ++i ; printf("%d",i);Result is five. Assuming standard C code. Left to right associativity is present for operators with equal precedence. ++i is evaluated first. The prefix operator RETURNS the incremented value. in this case, 1. 1 + i++ + ++i and i has the value 1. next, i++ is evaluated. this returns the value before increment; 1. 1 + 1 + ++i last, the prefix operator returns the incremented value, or three. 1 + 1 + 3 i changes value throughout the expression as it is evaluated. each increment operation is guaranteed to be complete before the value is used in an expression, so in that SENSE the binary + operators can be considered SEQUENCE points. thanx |
|