Why i++ is faster than i=i+1 in c


i=i+1:

To perform this operation compiler has to perform two operations:

(1)ADD      \\i+1
(2)Assignment operation          \i=x

i++:

To perform this operation compiler has to perform only one operation:

(1)INR

Note: above operation are microprocessor instructions i.e. in assembly language
so i++ is faster
Post a Comment