#include "iostream.h"
#include "conio.h"
class sum
{
public:
void great(float,float);
void great(float,float,float);
};
void main()
{
clrscr();
int op,a,b,c;
sum r;
jump:
cout <<"Welcome to find greatest no. using function overloading\n\n";
cout<<"please choose your option ie\n\n\t(2) \t\t\t(3)\n\t";
cin>>op;
if(op==2)
{
cout<<"please enter the two no.\n";
cin>>a>>b;
r.great(a,b);
}
else if(op==3)
{
cout<<"please enter the 3 no.\n" ;
cin>>a>>b>>c;
r.great(a,b,c);
}
else
{
cout<<"invalid option";
goto jump;
}
getch();
}
void sum::great(float x,float y)
{
if(x>y)
cout<<"the greatest no is "<
else if(y>x)
cout<<"the greatest no is" <
else
cout<<"both the no.s are equal";
}
void sum :: great(float x,float y,float z)
{
if(x>y&&x>z)
cout<<"the greatest no is "<
else if(y>x&&y>z)
cout<<"the greatest no is "<
else if(z>x&&z>y)
cout<<"the greatest no is "<
else
cout<<"all the no.s are equal";
}
Get the executable ( .exe ) file for this program..
Download
0 comments:
Post a Comment