menu search
person

Write a program in C++, to find maximum and minimum of two numbers using conditional operator.

thumb_up_alt 0 like thumb_down_alt 0 dislike
2 views

1 Answer

 
verified

#include<iostream>

using namespace std;


int main()

{

    int num1, num2, max, min;


    cout<<"Enter two numbers:"; 

    cin>>num1>>num2;


    max = (num1 > num2) ? num1 : num2;

min = (num1 < num2) ? num1 : num2;


    cout<<"Maximum between "<<num1<<" and "<<num2<<" is "<<max<<endl;

    cout<<"Minimum between "<<num1<<" and "<<num2<<" is "<<min<<endl;


    return 0;

}


Output::

image


thumb_up_alt 0 like thumb_down_alt 0 dislike
...