Parentheses Priority in C++
Level 128 keystrokes
Uses parentheses to add 2 and 3 first, then multiplies by 4 and prints 20.
C++ code
// Without parentheses * goes first: 2 + 3 * 4 would be 2 + 12 = 14// The parentheses force the addition first: (2 + 3) * 4 = 5 * 4 = 201cout << (2 + 3) * 4 << endl;Output
20
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;× 1(× 1)× 1*× 1+× 1