Answer to Question #152760 in C++ for Arslan khan

Question #152760
Write a program which takes as input two integers and then displays the maximum of the two numbers. You HAVE to use a ternary operator for this purpose.
1
Expert's answer
2020-12-28T12:53:10-0500
#include <iostream>
using namespace std;

int main()
{
    int firstNum, secondNum;
    cout << "Enter first integers: ";
    cin >> firstNum;
    cout << "Enter second integers: ";
    cin >> secondNum;
    // print the greater number out of the given two numbers
    cout << "max :" << (firstNum > secondNum ? firstNum : secondNum);
    return 0;
}

Output:

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog