+ 2
What is the difference between a++ and ++a?
4 Answers
+ 10
'++a' is pre-fix
'a++' is post-fix
This just means that in '++a' the operation of incrementing 'a' is done BEFORE the 'a' is processed by a function (i.e. cout).
In 'a++' the operation to increment is done AFTER 'a' is processed by a function
(i.e. cout).
cout << ++1 OUTPUT: 2
cout << 1++ OUTPUT: 1
Hope this helps!
-bern
+ 4
https://www.sololearn.com/Discuss/160327/?ref=app
the increment operator works the same in the majority of languages.
+ 2
yea like
int i = 5;
int k = 1;
int a = i + k++ // a = 6
// k is now 2
vs
int i = 5;
int k = 1;
int a = i + ++k // a = 7
// k is now 2
+ 2
Thank you all