Compound Assignment in C++
Level 246 keystrokes
Changes x with the compound assignment operators += and *=: 10 becomes 15, then 30, and 30 is printed.
C++ code
// Initializes x with 101int x = 10;// x += 5 is short for x = x + 5, so x becomes 152x += 5;// x *= 2 is short for x = x * 2, so x becomes 303x *= 2;// Prints the final value, 304cout << x << endl;Output
30
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.
;× 4<× 4=× 3*× 1+× 1