Programming Examples

Write a program to print the five entered numbers in the ascending order


Write a program to print the five entered numbers in the ascending order.

Solution

#include<stdio.h>
void main()
{
int a,b,c,d,e,sum=0,i;
clrscr();
printf(“\nEnter Five numbers :”);
scanf(“%d %d %d %d %d”,&a,&b,&c,&d,&e);
printf(“\n Numbers in ascending order :”);
sum=a+b+c+d+e;
for(i=1; i<=sum;i++)
{
 if(i==a || i==b || i==c || i==d || i==e)
 {
 printf(“%3d”,i);
 }
}
}
▶ RUN

Output/ Explanation:

OUTPUT:

Enter Five numbers : 5 8 7 4 1

Numbers in ascending order : 1 4 5 7 8

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad