Why n++ executes faster than n+1?

The expression n++ requires a single machine instruction such as INR to carry out the increment operation whereas, n+1 requires more instructions to carry out this operation.

Showing Answers 1 - 5 of 5 Answers

pushkarraj

  • Oct 24th, 2006
 

n++ uses unary operator while n+1 uses binary operator thats why it takes less instruction in n++ rather than n+1, that's why n++ is faster.

  Was this answer useful?  Yes

romainn

  • Jun 14th, 2007
 

n++ takes more than one instruction, ++n is faster. n++ has to store n, increment the variable and return n, while ++n increment n and return without storing the previous value of n.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions