Write a program which input three numbers and display the largest number using ternary operator.
Source Code
#include <iostream>
using namespace std;
int main()
{
int a,b,c,greatest;
cout<<"Enter three numbers : ";
cin>>a>>b>>c;
greatest=(a>b&&a>c)?a:(b>c)?b : c;
cout<<"Greatest number is "<<greatest;
return 0;
}
Output
Enter three numbers : 78 98 16 Greatest number is 98