#include<iostream.h>
#include<conio.h>
double power(double,int=2);
int main()
{
clrscr();
double m,n;
int v;
cout<<"\n\nEnter the base as a double number : ";
cin>>m;
cout<<"\n\nEnter the power as a integer number : ";
cin>>v;
n=power(m,v);
cout<<"\n\n"<<m<<" raised to "<<v<<" is "<<n;
n=power(m);
cout<<"\n\n"<<m<<" raised to 2 is "<<n;
getch();
return 0;
}
double power(double x,int y)
{
double z=1;
for(int i=1;i<=y;i++)
z=z*x;
return z;
}

Post a Comment

Previous Post Next Post