Microsoft Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: Written Test
yes the ans would be 8 if you remove the 3rd comment..
first the value of i will be incremented (as it is pre increment)then
i=10-10+4+4 wud be evaluated and finally the post increment operation(j++)takes place twice
after evaluating 3rd statement post increment operation should take place for i too. so it should result in 9 then how 8?
In each of the three lines, a variable (i or j) is referenced more than once. As there are no sequence points in between such instructions, the behavior is undefined.
- Monish October 14, 2011Read this for further clarification about Sequence points in C/C++: c-faq.com/expr/seqpoints.html