Write two maximum functions. One of the function should find the maximum of two numbers. The other function should find the maximum of three numbers.
#include<iostream>
using namespace std;
int max(int a,int b){
return a>b?a:b;
}
int max(int a,int b,int c){
int max=a;
if(b>max)max=b;
if(c>max)max=c;
return max;
}
int main(){
int a,b,c;
cout<<"Enter three numbers : "<<endl;
cout<<"a : ";
cin>>a;
cout<<"b : ";
cin>>b;
cout<<"c : ";
cin>>c;
cout<<"The maximum of first two numbers are "<<max(a,b)<<endl;
cout<<"The maximum of the three numbers are "<<max(a,b,c)<<endl;
return 0;
}

Write two more functions for float
- float max(float a, float b)
- float max(float a, float b, float c)
If you write float functions with the above program. Note that the below mentioned functions can’t be written in the same program.
- float max(int a, int b)
- int max(int a, int b)
For overloading, you should change the number of parameters not the return type