#include<iostream.h>
void main()
{
char repeat='y';
while(repeat=='y')
{
int x,n,a=1,temp;
cout<<endl;
cout<<endl;
cout<<" Enter a number : ?\b";
cin>>x;
cout<<endl;
cout<<" Enter the power : ?\b";
cin>>n;
cout<<endl;
temp=n;
while(n>=1)
{
a = a * x;
n--;
}
cout<<endl;
cout<<endl;
cout<<temp<<"th"<<" power of "<<x<<" is equal to "<<a<<endl;
cout<<endl;
cout<<" Do you want to do it again ? (y/n) ";
cin>>repeat;
}
}
Output:
Enter a number : 4
Enter the power : 5
5th power of 4 is equal to 1024
Do you want to do it again ? (y/n) n
Press any key to continue |