/*write a c++ program which will find the maximum of 3 integer number
and maximum of 3 floating number using function overloading*/
#include<conio.h>
#include<iostream.h>
void max(int n1,int n2,int n3)
{
if(n1>n2&&n1>n3)
cout<<"the maximum number:-"<<n1;
else
if(n2>n3&&n2>n1)
cout<<"the maximum number:-"<<n2;
else
cout<<"the maximum number:-"<<n3;
}
void max(float n1,float n2,float n3)
{
if(n1>n2&&n1>n3)
cout<<"the maximum number:-"<<n1;
else
if(n2>n3&&n2>n1)
cout<<"the maximum number:-"<<n2;
else
cout<<"the maximum number:-"<<n3;
}
int main()
{
int no1,no2,no3;
float f1,f2,f3;
clrscr();
cout<<"\nenter three integer number:-";
cin>>no1>>no2>>no3;
max(no1,no2,no3);
cout<<"\nenter three float number:-";
cin>>f1>>f2>>f3;
max(f1,f2,f3);
getch();
return 0;
}
/*
enter three integer number:-6
5
8
the maximum number:-8
enter three float number:-1.1
2.5
8.5
the maximum number:-8.5
*/
and maximum of 3 floating number using function overloading*/
#include<conio.h>
#include<iostream.h>
void max(int n1,int n2,int n3)
{
if(n1>n2&&n1>n3)
cout<<"the maximum number:-"<<n1;
else
if(n2>n3&&n2>n1)
cout<<"the maximum number:-"<<n2;
else
cout<<"the maximum number:-"<<n3;
}
void max(float n1,float n2,float n3)
{
if(n1>n2&&n1>n3)
cout<<"the maximum number:-"<<n1;
else
if(n2>n3&&n2>n1)
cout<<"the maximum number:-"<<n2;
else
cout<<"the maximum number:-"<<n3;
}
int main()
{
int no1,no2,no3;
float f1,f2,f3;
clrscr();
cout<<"\nenter three integer number:-";
cin>>no1>>no2>>no3;
max(no1,no2,no3);
cout<<"\nenter three float number:-";
cin>>f1>>f2>>f3;
max(f1,f2,f3);
getch();
return 0;
}
/*
enter three integer number:-6
5
8
the maximum number:-8
enter three float number:-1.1
2.5
8.5
the maximum number:-8.5
*/
No comments:
Post a Comment