New course! Every coder should learn Generative AI!
Try a free lesson0
What is increment?
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
+ 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