Increment Operators in C
Level 271 keystrokes
Shows the difference between post-increment and pre-increment: x++ prints 5 and then raises x to 6, while ++x raises x to 7 first and prints 7. The output is 5, 6 and 7 on separate lines.
C code
// x starts at 51int x = 5;// Post-increment: x++ passes the old value 5 to printf, then x becomes 62printf("%d\n", x++);// Prints 6, showing that the previous line did increase x3printf("%d\n", x);// Pre-increment: ++x raises x to 7 first, then passes 7 to printf4printf("%d\n", ++x);Output
5 6 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.
"× 6;× 4+× 4,× 3(× 3)× 3\× 3%× 3=× 1