0 votes
1.4k views
in Programming by (98.9k points)
edited

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

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer

#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


Related questions

0 votes
1 answer 1.3k views
0 votes
1 answer 152 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...