C Program to Arrange the given Numbers in Descending order using Array


SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,c,i,j;
clrscr();
printf("Enter the total number of values:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter Number %d : ",i+1);
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]<a[j])
{
c=a[i];
a[i]=a[j];
a[j]=c;
}
}
}
for(j=0;j<n;j++)
{
printf("\t%d",a[j]);
}
getch();
}
Previous
Next Post »

Still not found what you are looking for? Try again here.