Create a function power() to raise a number m to power n, the function takes a double value for m and int value for n,and returns the result correctly. Use the default value of 2 for n to make the function calculate squares when this argument is omitted. Write a main that gets the values of m and n from the user to test the function.
#include<iostream.h>
#include<conio.h>
double
power(double m,int n=2)
{
int
a=1,i;
for(i=0;i
a*=m;
return a;
}
void
main()
{
int x,y;
double c;
clrscr();
cout<<"enter the value of x;"
;
cin>>x;
c=power(x);
cout<<c<<endl;
cout<<"enter the value of x;";
cout<<x;
cout<<"\n enter the value of
y;";
cin>>y;
c=power(x,y);
cout<<c;
getch();
}