/* Function Overloading is a Popular C++ Technique in Which a Functions of Same name works in a Different Methods, Functions can be Different in Following Aspects:
1- Number of Parameters
2-Types of Parameters
3-Difference in Return Type */
#include<iostream>using namespace std;
void max(int a,int b);
int max(int m,int n,int o);
void max(char a, char b, char c);
float max(float w,float x,float y);
int main()
{
int j,k,l;
char c,h,r; //Declaration of 3 Characters
float f1,f2; // Floating Numbers
cout<<"\n Enter Two Integers: ";
cin>>j>>k;
max(j,k);
cout<<"\n Enter Three Integers: ";
cin>>j>>k>>l;
cout<<"\n Maximum is "<<max(j,k,l)<<endl;
cout<<"\n Enter Three Characters: ";
cin>>c>>h>>r;
max(c,h,r);
cout<<"\n Enter Two Decimal Values: ";
cin>>f1>>f2;
cout<<"\n Maximum is = "<<max(f1,f2)<<endl;
cout<<"\n\t***************************\n";
system("pause");
}
void max(int a,int b)
{
if(a>b)
cout<<"\n "<<a<<" is Maximum"<<endl;
else
cout<<"\n "<<b<<" is Maximum"<<endl;
}
int max(int m,int n,int o)
{
int mx=0;
if(m>mx)
mx=m;
if(n>mx)
mx=n;
if(o>mx)
mx=o;
return mx;
}
void max(char a, char b, char c)
{
if(a>b && a>c)
cout<<"\n "<<a<<" is Maximum"<<endl;
else if(b>a && b>c)
cout<<"\n "<<b<<" is Maximum"<<endl;
else
cout<<"\n "<<c<<" is Maximum"<<endl;
}
float max(float w,float x,float y)
{
if(w>x && w>y)
return w;
else if(x>w && x>y)
return x;
else
return y;
}
www.fb.com/MATEEGOJRA
0 comments: