Editorial / Best Answer
sahasranaman
p++ is faster because on compilation, it gets translated to three machine
instructions, where as p=p+1 needs four machine instructions. All machine
instructions take the same time.
For p++, the instructions are:
mov ax,
inc ax
mov,
ax
For p = p+ 1, the instructions would be,
mov ax,
mov bx, 1
add bx
mov,
ax
This is why p++ is faster than p+1
Register Relation
Profile Answers by akshay201989 Questions by akshay201989
Questions by akshay201989
Editorial / Best Answer
sahasranamanProfile Answers by sahasranaman Questions by sahasranaman
p++ is faster because on compilation, it gets translated to three machine instructions, where as p=p+1 needs four machine instructions. All machine instructions take the same time.
For p++, the instructions are:
mov ax,
inc ax
mov,
ax
For p = p+ 1, the instructions would be,
mov ax,
mov bx, 1
add bx
mov,
ax
This is why p++ is faster than p+1
Related Answered Questions
Related Open Questions