LATEST PROGRAMS

WAP in C++ to find largest number among three numbers, using ternary operator.

#include<iostream.h>
using namespace std;

int main()
{
    int a, b, c;
    cout<<"Enter the three numbers \n";
    cin>>a>>b>>c;
    cout<<"Entered numbers are :\n";
    cout<<a<<" "<<b<<" "<<c;
    int d=(a<b)?(b>c ? b:c) : (a>c ? a:c);
    cout<<"\nThe largest number is : "<<d;
    return 0;
}
18/02/2023, 12:29 am Read : 111 times