Write
a program to accept three number and display these number in ascending order.
#include<iostream.h>
void main()
{
int
a,b,c;
cout
<< "Enter 3 numbers ";
cin
>> a >> b >> c;
if( a<=b
&& a<=c)
{ cout << a << ", " ;
if(
b<=c )
cout
<< b << ", " << c;
else
cout
<< c << ", " << b;
}
if( b<=a && b<=c)
{ cout << b << ", " ;
if(
a<=c )
cout
<< a << ", " << c;
else
cout
<< c << ", " << a;
}
if( c<=b && c<=a)
{ cout << c << ", " ;
if(
a<=b )
cout
<< a << ", " << b;
else
cout
<< b << ", " << a;
}
}
No comments:
Post a Comment