0

i need help in this program. The program question is: A function power which will calculate a number m to the power n (m^n). You will pass two parameters float & int. If the parameter n is omitted then it should taken as 2.

i hope u all got the question.. i did the program but here it is going reverse, what i mean is 6^2 should return me the ans 36 but i'm getting the ans 64.. Y..?? Plz help..!!

```
#include<iostream.h>
#include<conio.h>
#include<math.h>
float power(float m, float n=2.0)
{
float p=1;
int i;
for(i=1;i<=m;i++)
{
p=p*n;
}
return p;
}
void main()
{
float n,z;
int m;
clrscr();
cout<<"\n Enter the value of m: \n";
cin>>m;
cout<<"\n Enter the value of n: \n";
cin>>n;
if(n==0)
{
z=power(m);
cout<<"\n The resultant value is: \n"<<z;
}
else
{
z=power(m,n);
cout<<"\n The resultant value is: \n"<<z;
}
getch();
}
```