Increment operators | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Increment operators

What is the difference between the prefix and postfix increment operators it's really confusing when used in a code. What would be delighted output of this code. int a= 5; int b= 4; b= a++; cout << b;

27th Jul 2017, 11:46 AM
Ibrahim
Ibrahim - avatar
2 Answers
27th Jul 2017, 1:46 PM
Hatsy Rei
Hatsy Rei - avatar
0
Prefix: makes increment, return you original object Postfix: makes copy with old value, increments value, returns you old copy. In statements returned values are used.
27th Jul 2017, 11:51 AM
soman