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
5 comments:
Very helpful...........
Gud :)
gr8
nice. but internally compiler may use optimization techniques to replace all forms of incrementing the value of i with i++.....
type two .c file in linux and then check assembly code
1.c
main()
{
int i =0;
i++;
}
2.c
main()
{
int i =0;
i=i+1;
}
in my system assembly code for both the files are same.
so where is the difference?
Post a Comment