By | 25.12.2016

# Find Power of a Number using for loop

Write a C++ Program to Find Power of a Number using for loop. Here’s simple Program to Calculate Power of Number using for loop in C++ Programming Language.

The program below takes two integers from the user (a base number and Power to base) and calculates the power.

For example :: In case of 25

• 2 is the base number
• 5 is the power to the base number
• And, the power of number is equal to 2*2*2*2*2

Here is source code of the C++ Program to Find Power of a Number using for loop. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.

### SOURCE CODE : :

```/*  C++ Program to Find Power of a Number using for loop  */

#include<iostream>
using namespace std;

int main()
{
int b,p,i,pow=1;
cout<<"Enter base of a number :: ";
cin>>b;
cout<<"\nEnter power to a base [ "<<b<<" ] :: ";
cin>>p;

for(i=p;i>0;i--)
{
pow=pow*b;
}
cout<<"\nPower of a Number [ "<<b<<" ^ "<<p<<" ] :: "<<pow<<"\n";

return 0;
}```

### Output : :

```/*  C++ Program to Find Power of a Number using for loop  */

Enter base of a number :: 2

Enter power to a base [ 2 ] :: 6

Power of a Number [ 2 ^ 6 ] :: 64

Process returned 0```

Above is the source code for C++ Program to Find Power of a Number using for loop which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

Thanks for reading the post…. 