c program to arrange three numbers in ascending order without using array. or
Ascending order program in c-language using
if-else.
#include<stdio.h>
#include<conio.h>void main()
{
int a,b,c,n,m,p;
clrscr();
printf("Enter the three number \n");
scanf("%d%d%d",&a,&b,&c);
if(a<b&&a<c&&b<c)
{
n=a;
m=b;
p=c;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a>b&&a>c&&b>c)
{
n=c;
m=b;
p=a;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a>b&&a>c&&b<c)
{
n=b;
m=c;
p=a;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a<b&&a>c&&b>c)
{
n=c;
m=a;
p=b;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a<b&&a<c&&b>c)
{
n=a;
m=c;
p=b;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a>b&&a<c&&b<c)
{
n=b;
m=a;
p=c;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a==b&&b<c)
{
n=a;
m=b;
p=c;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a==c&&b<c)
{
n=b;
m=a;
p=c;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a==c&&b>c)
{
n=a;
m=c;
p=b;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a<b&&b==c)
{
n=a;
m=b;
p=c;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a>b&&b==c)
{
n=b;
m=c;
p=a;
printf("Ascending order is= %d %d %d",n,m,p);
}
else if(a==b&&b>c)
{
n=c;
m=b;
p=a;
printf("Ascending order is= %d %d %d",n,m,p);
}
getch();
}
ascending order program ,output |
Program in c language using if-else condition.
0 Comments