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

 

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

void main()
{
clrscr();

int a,b;

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

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

getch();
}

 

< Back