Which is the correct statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 14

Which is the correct statement?

preincrement is faster than postincrement postincrement is faster than preincrement none

2nd Sep 2017, 3:57 AM
Angelin Blessy
2 Answers
+ 12
pre-increment generally is faster and requires less memory than post-increment.
2nd Sep 2017, 4:00 AM
Amit Mathew
0
Post-increment usually involves keeping a copy of the previous value around and adds a little extra code. Pre-increment simply does it's job and gets out of the way. I typically pre-increment unless the semantics would change and post-increment is actually necessary. thus preincrement requires less memory and so faster.
3rd Sep 2017, 1:18 PM
NEELKUMAR PATEL
NEELKUMAR PATEL - avatar