write a program in c-language to arrange the 10 natural numbers in ascending order.
In this program, we will sort the given array in ascending order and user will enters the 10 natural number and this 10 natural number are arrange smallest to largest number.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,j,temp;
printf("enter the 10 number\n");
for(i=1;i<=10;i++)
scanf("%d",&a[i]);
for(i=1;i<=10;i++)
printf("%d ",a[i]);
for(i=1;i<=10;i++){
for(j=i+1;j<=10;j++){
if(a[i]>a[j]){
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("\nascending order are follow :\n");
for(i=1;i<=10;i++)
printf(" %d",a[i]);
getch();
}
output are follow:-

No comments:
Post a Comment