Solution Review: Calculate the Power of a Number
Let's see the detailed solution review of the challenge given in the previous lesson.
We'll cover the following...
Solution #
Press + to interact
#include <iostream>using namespace std;int main() {// Initialize variableint base = 2, exponent = 3, result = 1;// for loop initializationfor (int counter = 1; counter <= exponent; counter++) {// for loop bodyresult *= base;}// Exit for loopcout << result;return 0;}