Why preincrement operator is faster than postincrement?

Answers were Sorted based on User's Feedback



Why preincrement operator is faster than postincrement?..

Answer / sanish joseph

the pre inc operator increments the value of that particular
variable on that line itself

the post inc operator increments the value of that
particular variable after going on the next line

in simple words

eg.

e=5; on this line value of e=5

e++; on this line value of e=5

++e; on this line value of e=7

Is This Answer Correct ?    27 Yes 9 No

Why preincrement operator is faster than postincrement?..

Answer / devesh patel

b/c preeincrement take one byte instruction & post
increment takes two instruction

Is This Answer Correct ?    16 Yes 7 No

Why preincrement operator is faster than postincrement?..

Answer / ranjeet garodia

Pre increment operator is use the concept of value by
reference that means it increment the actual object.

While post increment use call by value concept that is it
create the local object, operate on that, then it will
increment actual object, so takes time to create local
object

Is This Answer Correct ?    10 Yes 7 No

Why preincrement operator is faster than postincrement?..

Answer / shakti singh khinchi

Because post increment operator uses a temporary variable to
store the incremented value for a variable until it is used
in the next executed statement, whereas pre increment
operator not using any temp variable, it is just increase
that value at the time of execution using reference.

Is This Answer Correct ?    3 Yes 1 No

Why preincrement operator is faster than postincrement?..

Answer / puneet nagpal

postincrement did not increment unless it find ; so it increments after the end of statement. while the preincrement operator increment before the end of statement. so preincrement operator is faster than postincrement operator.
ex- a=10;
a++;value incremented after the end of statement but
at this point value is 10.
a++;now the value is incremented to 11.
++a; preincrement incremented within the statement now
the value is 12.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is the Difference between "C structure" and "C++ structure"?

12 Answers  


What is the Difference between "printf" and "sprintf"?

7 Answers   iSoft, PentaWare, TCS,


Why is it difficult to store linked list in an array?

6 Answers   Infosys, Lucent,


Define a program that reads two matrices of size 3x3 with real values from the user then prints their sum, difference and multiplication.

0 Answers   TCS,


Do class declarations end with a semicolon?

0 Answers  






Incase of a function declaration, what is extern means?

0 Answers  


Which programming language is best to learn first?

0 Answers  


What is a driver program?

0 Answers  


Can a built-in function be recursive?

0 Answers  


If you don’t declare a return value, what type of return value is assumed?

0 Answers  


Which one is a preferred language C or C++? Why?

0 Answers  


What is a constructor and how is it called?

0 Answers  


Categories