Monday, 25 March 2019

CPP-EX72

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();
}