0
Increment and decrement
If a=10 so if we write ++a it gives 11 but by mathematical way it gives 20
3 Answers
+ 8
The increment and decrement operators (++, --) increment and decrement numeric types by 1.
The operator can either precede or follow the variable, depending on whether you want the variable to be updated 'before' or 'after' the expression is evaluated.
ā¢ The prefix: increments the value of x,
Ā and then assigns it to y.
Ā Ā Ā Ā Ā int x = 5;
Ā Ā Ā Ā Ā int y = ++x;Ā // x is 6, y is 6
ā¢ The postfix: assigns the value of x to y,
Ā and then increments x.
Ā Ā Ā Ā Ā int x = 5;
Ā Ā Ā Ā Ā int y = x++;Ā // x is 6, y is 5
ā¢ https://www.sololearn.com/post/150404/?ref=app
ā¢ https://code.sololearn.com/chPAcDs7YZgV/?ref=app
ā¢ https://code.sololearn.com/cm4wSfJZ8h28/?ref=app
+ 4
In programming it just increases the value by 1.
+ 1
Hi!
a++ stands for a = a + 1
a = 10
a++ --> 10 + 1 --> 11
To have the result of 20 you should have:
a = 10
a += a --> a = a + a --> 20
https://www.programiz.com/article/increment-decrement-operator-difference-prefix-postfix
https://en.m.wikipedia.org/wiki/Increment_and_decrement_operators