What is pre increment and post increment? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is pre increment and post increment?

1st Jun 2017, 11:10 AM
Hyde
3 Answers
+ 3
Let int x=5 Pre increment:(++x) :: First increases the value of x by 1 and then uses new value . Post increment:(x++)::First uses the value of x(i.e. 5) and then increases the value by 1 .
1st Jun 2017, 11:22 AM
Ishan
Ishan - avatar
+ 3
pre increment: int a = 5 int b = ++a a and b will be equals 6 because a is incremented before assignment. post increment: int a = 5 int b = a++ b will be equals 5 whilst a is equals 6 because a is incremented after assignment.
1st Jun 2017, 11:23 AM
Heinrich Cilliers
Heinrich Cilliers - avatar