Monday, February 16, 2015
C Program to print three numbers in descending order
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,big1,big2,big3;
cout<<"Enter three numbers:";
cin>>a>>b>>c;
big1=a;
if(b>big1)
big1=b;
else
if(c>big1)
big1=c;
if(big1==a)
{
if(b>c)
{
big2=b;
big3=c;
}
else
{
big2=c;
big3=b;
}
}
else
{
if(big1==b)
if(a>c)
{
big2=a;
big3=c;
}
else
{
big2=c;
big3=a;
}
else
{
if(a>b)
{
big2=a;
big3=b;
}
else
{
big2=b;
big3=a;
}
}
}
cout<<"
Numbers in descending order......
";
cout<<big1<<" "<<big2<<" "<<big3;
getch();
}
#include<conio.h>
void main()
{
clrscr();
int a,b,c,big1,big2,big3;
cout<<"Enter three numbers:";
cin>>a>>b>>c;
big1=a;
if(b>big1)
big1=b;
else
if(c>big1)
big1=c;
if(big1==a)
{
if(b>c)
{
big2=b;
big3=c;
}
else
{
big2=c;
big3=b;
}
}
else
{
if(big1==b)
if(a>c)
{
big2=a;
big3=c;
}
else
{
big2=c;
big3=a;
}
else
{
if(a>b)
{
big2=a;
big3=b;
}
else
{
big2=b;
big3=a;
}
}
}
cout<<"
Numbers in descending order......
";
cout<<big1<<" "<<big2<<" "<<big3;
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.