using namespace std;
double power(double n,int p=2)
{
double x=1.0;
int i;
for (i=0;i
x*=n;
return x;
}
int main()
{
double m,res;
int q;
char ch;
cout<<"Enter a number to be raised to a power: ";
cin>>m;
cout<<"Do you want to enter the power (Y/N): ";
cin>>ch;
if ((ch=='y')||(ch=='Y'))
{
cout<<"Enter the power to which the number "<
res=power(m,q);
}
else
res=power(m);
cout<<"The result is: "<<res;
}
can you give output in turbo screen
ReplyDelete