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

getch();
}

 

< Back