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

What is increment?

2nd May 2017, 1:56 PM
para
2 Answers
+ 12
To add a value to an integer example: x++ it uses the value of x then adds 1 to it decrement example: ++x adds 1 to the value of x and uses it EXAMPLE: int a = 10; int b = a++; //The value of b is still 10 because it used the value of a first int a = 10; int b = ++a; //Now b is 11
2nd May 2017, 1:57 PM
Complex
Complex - avatar
+ 4
example 1: x=1 y=++x result --> now is x=2 and y=2 --------------- example 2: x=1 y=x++ result --> now is x=2 and y=1
2nd May 2017, 1:58 PM
Nikola Stojiljkovic
Nikola Stojiljkovic - avatar