Monday 27 August 2012

c program for sorting of arrays in descending order

 c program for sorting of arrays in descending order
How to write a program for sort  numbers in c code descending order
#include<stdio.h>
void sort(int a[]);
void main()
{
  int a[10],i;
  clrscr();
  printf("\nEnter 10 elements in array:");
  for(i=0;i<10;i++)
  scanf("%d",&a[i]);
  sort(a);
}
void sort(int a[10])
{
  int temp,i,j;
  printf("\nArray in Ascending Order:");
  for(i=0;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;
     }
  }
  for(i=0;i<10;i++)
  printf("%d  ",a[i]);
  printf("\n\nArray in Descending Order:");
  for(i=9;i>=0;i--)
  printf("%d  ",a[i]);
}
array  sort examples
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: