![]() |
post & pre increment question - very confusing
Please help me with this, I am having a hard time!!!
Code:
main()so isnt x=x++ and x++ same?? secondly Code:
main()Thanks guys |
Re: post & pre increment question - very confusing
First, read "Before you make a query". If you already have, then you're just being rude.
Secondly, the operations you're performing result in undefined operation. The compiler can do anything it likes, including melt your system into a slag heap. Read about sequence points. |
Re: post & pre increment question - very confusing
x = x++;
You are assigning the value to the variable and then incrementing it and so it is 10 y = ++y; You are incrementing the value and then assigning it and so its one more than the original value. x=y++ + x++; y= ++y + ++x; For this try evaluating from Right to left because C is normally Right To Left evaluated and almost all the compilers follow that but as DaWei said you are at the mercy of the compiler to give you results. |
| All times are GMT +5.5. The time now is 23:17. |