menu search
person

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

thumb_up_alt 50 like thumb_down_alt 0 dislike
10 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 50 like thumb_down_alt 0 dislike

Related questions

thumb_up_alt 50 like thumb_down_alt 0 dislike
42 views 1 answer
thumb_up_alt 50 like thumb_down_alt 0 dislike
27 views 1 answer
thumb_up_alt 51 like thumb_down_alt 0 dislike
775 views 1 answer
thumb_up_alt 50 like thumb_down_alt 0 dislike
12 views 1 answer
thumb_up_alt 50 like thumb_down_alt 0 dislike
17 views 1 answer
add_circle_outline
...