C++

C++ Program to Calculate the Power of a Number Using While Loop

In this program, base and exponent are assigned values 3 and 4 respectively.

Using the while loop, we keep on multiplying result by base until exponent becomes zero.




In this case, we multiply result by base 4 times in total, so result = 1 * 3 * 3 * 3 * 3 = 81.

C++ Code:

 

Leave a Comment