#include <iostream.h>
#include <conio.h>
#include<math.h>double power(int m, int n = 2)
{
double res = pow(m,n);
return res;
}
void main()
{
int x;
cout<< "\n Enter a number to calculate its square :";
double d = power(x);
cout<< "\n The square of " << x <<"is " << d;
cout<< "\n Enter a number to calculate its cube :";
d = power(x,3);
cout<< "\n The cube of " << x <<"is " << d;
int y;
cout<< "\n Enter a number and its power to calculate the result :";
cin>>x>>y;
d = power(x,y);
cout<< "\n The " << x << " to the power " << y <<" is " << d;
getch();
}
No comments:
Post a Comment