Exponentiation in C++
Level 128 keystrokes
Computes 2 to the power of 3 by multiplying 2 three times and prints 8.
C++ code
// C++ has no power operator like ** (std::pow from <cmath> computes powers)// For a small integer power, repeated multiplication works: 2 * 2 * 2 is 81cout << (2 * 2 * 2) << endl;Output
8
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*× 2;× 1(× 1)× 1