Example:5
Program to print maximum of three numbers.
#include <iostream>
using namespace std;
inline int Max(int x, int y,int z)
{
return ((x>y && x>z)?x:(y>z)?y:z);
}
// Main function for the program
int main()
{
int a,b,c;
cout<<"Enter 3 nos ";
cin>>a>>b>>c;
cout << "Max no : " << Max(a,b,c) << endl;
cout << "Max no : " << Max(10,23,200) << endl;
cout << "Max no : " << Max(100,46,1010) << endl;
return 0;
}
Output:
Enter 3 nos 25
96
68
Max no : 96
Max no : 200
Max no : 1010
Example:6
Program to print minimum of three numbers.
#include <iostream>
using namespace std;
inline int Min(int x, int y,int z)
{
return ((x<y && x<z)?x:(y<z)?y:z);
}
// Main function for the program
int main()
{
int a,b,c;
cout<<"Enter 3 nos ";
cin>>a>>b>>c;
cout << "Min no : " << Min(a,b,c) << endl;
cout << "Min no : " << Min(10,23,200) << endl;
cout << "Min no : " << Min(100,46,1010) << endl;
return 0;
}
Output:
Enter 3 nos 25
63
34
Min no : 25
Min no : 10
Min no : 46




