Lab07
Lab07
/*Write a function that performs the same operation as that of the last program but
takes an int value for m. Both the functions should have the same name. Write a main
that calls both the functions.
*/
#include <iostream>
using namespace std;
double pow(double m,int n=2)
{
double res=1;
for(int i=1;i<=n;i++)
res*=m;
return res;
}
double pow(int m,int n=2)
{
double res=1;
for(int i=1;i<=n;i++)
res*=m;
return res;
}
int main()
{
double n;
int n2,n;
cout<<"Enter Number : ";
cin>>n1;
cout<<"Enter Power : ";
cin>>n;
cout<<num1<<" raised to the power "<<n<<"= "<<pow(n1,n)<<endl;
cout<<"Enter Number : ";
cin>>n2;
cout<<"Enter Power : ";
cin>>n;
cout<<num2<<" raised to the power "<<n<<"= "<<pow(n2,n);
}
Output