C++ Program to Calculate the Power of a Number Using While Loop – Programming Code Examples
C++

C++ Program to Calculate the Power of a Number Using While Loop1 min read

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