C/c programming--> pointers
Expert: Narendra - 3/30/2004
Question-------------------------
Followup To
Question -
i m using linux 9.0
this question is asked in the interview.
why preincrem,ent operator is faster than post increment operator?
Answer -
>why preincrem,ent operator is faster than post increment operator?
I don't think this is true!
Everything depends on the implementation and according to ANSI C standards, there is no difference in the speeds!
-ssnkumar
i m sorry to say that i m not satisfied with your answer .someone has told me that for preincrement implementation it passes value by reference but for postincrement operator it passes value by value thats why preincrement is faster than post increment.
hope u will reply soon
thanking you
AnswerThe concept of "passing by reference" itself is alien to C.
And the post/pre-increment are not functions, they are operators. So, both of them have to increment whatever value is sent to them.
If you understand the concept of passing by value, you will know that the value of the variable sent to the function will remain unchanged.
As you are thinking if post increment passes the argument as "pass by value", then the value should not change at all. But, on the contrary, it also changes the value of the argument!
-ssnkumar