Write a program that asks the user to enter two numbers. The program should use the Conditional operator to determine which number is smaller and which is larger

Write a program that asks the user to enter two numbers. The program should use the Conditional operator to determine which number is smaller and which is larger

code :
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cout << "Enter the value of x";
cin >> x;
cout << "Enter the value of y";
cin >> y;
int z = x > y ? x : y;
cout << z;
return 0;
}

output:
Enter the value of x20
Enter the value of y10
20

Post a Comment

0 Comments