Write a program to find the greatest number out of the 3 numbers inputted by the user, using conditional operators.

 

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int a,b,c;

cout<<"Enter first number:";
cin>>a;
cout<<"Enter second number:";
cin>>b;
cout<<"Enter third number:";
cin>>c;

cout<<"The greatest number is:";
a>b?(a>c?cout<<a:cout<<c):(b>c?cout<<b:cout<<c);

getch();
}

 

< Back