#include<iostream.h>
int main()
{
int b,e;
cout<<"enter a base value:";
cin>>b;
cout<<"enter a exponent Value:";
cin>>e;
long int r=b;
while (e>1)
{
e=e-1;
r=b*r;
}
cout<<r;
return 0;
}
Another program with different method in visual studio
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int b;
int p;
int temp;
cout<<"Enter the value of base = "; cin>>b;
cout<<"Enter the value of power = "; cin>>p;
temp = b;
while(p>1)
{
b = b* temp;
p--;
}
cout<<"the power of the value is as under = "<<b;
_getch();
}