#include <iostream.h>
#include <conio.h>
void main()
{
double power(double m,int n=2);
clrscr();
cout<<endl<<endl<<endl;
int choice,m,n;
double result;
do
{
cout<<"\n\n\nCHOICES\n\n";
cout<<"1) Only Value of M\n";
cout<<"2) Value for both M and N\n";
cout<<"3) QUIT\n";
cout<<"ENTER YOUR CHOICE:-";
cin>>choice;
clrscr();
cout<<endl<<endl<<endl;
switch(choice)
{
case 1 : cout<<"Enter Value for M:-";
cin>>m;
result=power(m);
cout<<"Power function when default argument is used ="<<result;
break;
case 2 : cout<<"Enter Value for M and N:-";
cin>>m>>n;
result=power(m,n);
cout<<"Power function when actual argument is use ="<<result;
break;
case 3 : goto out;
default: cout<<"Entered Value is Invalid, Try again";
}
}while(choice!=3);
out:
}
double power(double m,int n)
{
double pow=1,k=0;
for(int i=0;i<n;i++)
{
pow=pow*m;
}
return(pow);
}
#include <conio.h>
void main()
{
double power(double m,int n=2);
clrscr();
cout<<endl<<endl<<endl;
int choice,m,n;
double result;
do
{
cout<<"\n\n\nCHOICES\n\n";
cout<<"1) Only Value of M\n";
cout<<"2) Value for both M and N\n";
cout<<"3) QUIT\n";
cout<<"ENTER YOUR CHOICE:-";
cin>>choice;
clrscr();
cout<<endl<<endl<<endl;
switch(choice)
{
case 1 : cout<<"Enter Value for M:-";
cin>>m;
result=power(m);
cout<<"Power function when default argument is used ="<<result;
break;
case 2 : cout<<"Enter Value for M and N:-";
cin>>m>>n;
result=power(m,n);
cout<<"Power function when actual argument is use ="<<result;
break;
case 3 : goto out;
default: cout<<"Entered Value is Invalid, Try again";
}
}while(choice!=3);
out:
}
double power(double m,int n)
{
double pow=1,k=0;
for(int i=0;i<n;i++)
{
pow=pow*m;
}
return(pow);
}
0 comments:
Post a Comment