becuase number of assembly instructions are less (however nowadays compiler are smart enough to optimize both ++i and i++ )
2007-03-29 21:51:43
·
answer #1
·
answered by Anonymous
·
1⤊
0⤋
Because the language can load and add 1 in one step, then use the result. To increment later, the value just used must be loaded again, the addition of 1 done and the value put back in a register for use later. Simply said, in any system, there are 1 or 2 less steps possible in pre vs post increment
2007-03-30 04:52:35
·
answer #2
·
answered by Mike1942f 7
·
1⤊
0⤋
preincremental operator is faster than postincremental operator only in those cases where operation is done on the variable after incrementation.
Consider the example a[x++]........what happens here is that if x=7, then a[7] is to be done and then x is to be loaded again ad then incremented.{ x is loaded, a[;....] is performed, x is again loaded and then incremented.]
While in case of a[++x], the value of x is loaded, incremented and then a[....] is performed.
So the number of assembly langusae steps required is less for a preincremental than taht of a post incremental.
2007-03-30 05:52:04
·
answer #3
·
answered by chintu_victor 1
·
1⤊
0⤋