Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

Write a function called power that takes double value for n and int value for p and return the result as double. use default argument of 2 for p if this argument is omitted.


#include<iostream.h>
#include<conio.h>
double power (double n,int p=2)
{
int count;
int r=1;
for(count=1;count<=p;count++)
{
r=r*n;
}
return r;
}
int main()
{
double a,b;
int c;
clrscr();
cout<<"Enter no.";
cin>>a;
cout<<"Enter power";
cin>>c;
b=power(a,c);
cout<<"Result="<<b;
return 0;
}

  

Output


Previous
Next Post »