Pre/Post Increment in C++
Level 252 keystrokes
Shows the difference between post-increment and pre-increment: a++ prints the old value 5, then ++a raises a to 7 and prints 7.
C++ code
// Initializes a with 51int a = 5;// Post-increment: the expression gives the old value, so 5 is printed// a is increased afterwards and becomes 62cout << a++ << endl;// Pre-increment: a goes from 6 to 7 first, then 7 is printed3cout << ++a << endl;Output
5 7
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C++ code and how often they appear.
<× 8+× 4;× 3=× 1