C program to Sort an array of input ten elements in an descending order
#include<stdio.h>
#include<conio.h>
main()
{
int
a[10], i, j, temp;
printf("Enter
number\n");
for
(i=0;i<=9;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<=9;i++)
{
for(j=i+1;j<=9;j++)
{
if(a[i]<a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("\n
Sorted numbers (Descending)\n");
for(i=0;i<=9;i++)
printf("%d\n",a[i]);
getch();
}
Output:
No comments:
Post a Comment