#include < iostream.h>
#include < stdlib.h>
float power(double m,int n=2)
{
int i;
double result=1;
for(i=0;i< n;i++)
result*=m;
return result;
}
void main()
{
double num,res;
int powr;
cout<< " enter the number\n";
cin>>num;
cout<< " enter the power\n";
cin>>powr;
res=power(num,powr);
cout<< " the result is ----> "<< res;
}
Thursday, September 11, 2008
C++ program to write a function power() to raise a number m to a power n and taking default n value as 2
Posted by Nanya at 12:27 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment