in reply to Prefix and postfix increment/decrement operator query

Looks like your answer was very well covered by the other responders. Mine is just a nit since I think I know what you meant; but you said in your post:

"It should be 21 instead of 20 because..."

Did you mean "...11 instead of 10..." since you initialize your variable to 10 rather than to 20?

ack Albuquerque, NM
  • Comment on Re: Prefix and postfix increment/decrement operator query

Replies are listed 'Best First'.
Re^2: Prefix and postfix increment/decrement operator query
by saurabh.hirani (Beadle) on Jul 03, 2009 at 04:46 UTC
    Did you mean "...11 instead of 10..." since you initialize your variable to 10 rather than to 20?

    I was talking about the answer of the operation $a++ + $a--. But yes, as per your observation.the value of $a should be 11 instead of 10.