# Compute Power of a Number

“** Compute Power of a Number**” is again basic problem of programming for beginners. Here, we are given a base and exponent number, entered by users and our task is to write a program to compute the power of a number, base

^{exponent}.

2^{3} = 2 * 2 * 2 = 8

**Example**

Base = 2, Exponent = 3INPUT:8OUTPUT:

To compute the power of a number, simply loop can be used.

**C++ Program to compute Power of a Number is as follows:**

#include<bits/stdc++.h> using namespace std; int main() { //Scan the base and exponent int base,exponent; cout<<"Enter the base and exponent:"; cin>>base>>exponent; // Compute the Power int Power = 1; for(int i = 1 ; i <= exponent ; i++) { Power = Power * base; } // Printing the result cout<<Power; }

Enter the base and exponent: 2 3 8OUTPUT:

**Related Posts:**

**Program to find Quotient and Remainder.****Program to find largest amongst three numbers.****Program to find factorial of a number.****Program to find GCD of two numbers.****Program to find LCM of two numbers.****Program to check whether entered number is odd or even.****Program to check whether entered number is prime number or not.****Program to check whether entered number is palindrome or not.****Program to check whether entered number is Armstrong Number or Not.****Program to convert binary number to octal number.****Program to convert binary number to decimal number.****Program to convert binary number to hexadecimal number.****Program to convert octal number to binary number.****Program to convert octal number to decimal number.****Program to convert octal number to hexadecimal number.****Program to convert decimal number to binary number.****Program to convert decimal number to octal number.****Program to convert decimal number to hexadecimal number.****Program to convert hexadecimal number to binary number.****Program to convert hexadecimal number to octal number.**