25.Write a C++ program which will find the maximum of 3 integer numbers and maximum of 3 float numbers using function overloading.


#include<iostream.h>
#include<conio.h>
class over
{
public:
int get(int,int,int);
float get(float,float,float);
};
int over::get(int a,int b,int c)
{
if(a>b&&a>c)
return a;
else
{
if(b>a&&b>c)
return b;
else
return c;
}
}
float over::get(float a,float b,float c)
{
if(a>b&&a>c)
return a;
else
{
if(b>a&&b>c)
return b;
else
return c;
}
}
void main()
{
int n1,n2,n3,t;
float x,y,z;
over obj;
clrscr();
cout<<“\nEnter three integer number: “;
cin>>n1>>n2>>n3;
t=obj.get(n1,n2,n3);
cout<<“Maximum number is: “<<t;
cout<<“\nEnter three float number: “;
cin>>x>>y>>z;
float temp=obj.get(x,y,z);
cout<<“Maximum number is: “<<temp;
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s