This is simple....
Do you see the i++ part...
it's like this ++i makes the value of i 6
then iafter the division make the division of 6 with 6 and you get one...
which is stored in i
then the ++ makes it two....
Tell me if you didn't understand....
The answer is simple
i=(++i)/(i++)
First, ++i => i=6
Then, i++=> use six, and AT THE END OF THIS STATEMENT, ADD 1 to i
i=6/6=1
NOW, add 1 to i =>i=2
Hope that helps...
Arun
Dang the odds !!!!!
We made replies at the exact same time !!!
and in the similar fashion!!!
whatever the value of i the answer is 2
obviously
how come the division operator has higher precedence than '(' ?
Hi Nikhil,
It sure was a coincidence... What are the odds, 2 people posting the answer at the same time and in similar manner!!!
Harmax,
If you read my post or Nikhil's post carefully, and rework with any value of i manually, u will see the reason. It is not that division has higher priority over '(', but that it has higher priority over post-increment operator.
DKant,
Glad we could help...
Arun