Home >> Sem 2 >> C++ programs >> POWER
/* Write a CPP Program to find the power of input number */
#include<iostream.h>
#include<conio.h>
int power(int m,int n)
{
int ans=1,i;
for(i=1;i<=n;i++)
ans*=m;
return ans;
}
double power(double m,int n)
{
int i;
double ans;
for(i=1;i<=n;i++)
ans*=m;
return ans;
}
void main()
{
int a,b,ans;
clrscr();
cout<<"Enter Base of Number : ";
cin>>b;
cout<<"Enter Power of Number : ";
cin>>a;
ans=power(b,a);
cout<<"\nThe Answer : "<<ans;
getch();
}