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);
 }
}
}
Output

OUTPUT:

Enter Five numbers : 5 8 7 4 1

Numbers in ascending order : 1 4 5 7 8

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz