Write a program to find the smallest 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 smallest number is:";
b>a?cout<<a:cout<<b;

getch();
}

< Back