Write a C++ Program for Finding Power of Number.
/*Write a function power() to raise a number m to a power n. The
function takes a double value for m and int value for n and returns
the result correctly. Use a default value of 2 for n to make the
function to 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
#include
void main()
{
double power(double m,int n=2);
clrscr();
cout<
clrscr();
cout<
result=power(m);
cout<<"Power function when default argument is used ="<
result=power(m,n);
cout<<"Power function when actual argument is use ="<
break;
case 3 : goto out;
default: cout<<"Entered Value is Invalid, Try again";
}
}while(choice!=3);
out:
}
double power(double m,int n)
{
double pow=1,k=0;
for(int i=0;i
{
pow=pow*m;
}
return(pow);
}