Skip to content
Blog

Min and Max of Two Numbers in C++

By Published A short read

      This is how to  find minimum and maximum of two integer numbers in cpp using inline function and conditional operators. Nothing much in here very simple program

code:

#include<iostream>
using namespace std;
int main(){
    int a,b,min,max;
    cout<<"Enter two integer numbers: ";
    cin>>a>>b;
    min=a<b?a:b;
    max=a>b?a:b;
    cout<<"Min: "<<min<<endl;
    cout<<"Max: "<<max<<endl;

    system("pause");
    return 0;
}

output:

Find min max of two integers in cpp using inline function and conditional operatros
output