/*SELECTION SORT (ASCENDING AND DESCENDING ORDER ORDER) */
#include<stdio.h>
void main()
{
int n,a[1000],i,j,t,m,l;
printf("enter the number of numbers that are to be sorted\n");
scanf("%d",&n);
printf(" enter the elements of the array\n"); for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++) { t=i; for(j=i;j<n;j++) if(a[t]>a[j]) { t=j; } if(t!=i) { m=a[i]; a[i]=a[t]; a[t]=m; } }
printf("\n ASCENDING ORDER :\n"); for(i=0;i<n;i++)
printf(" %d ",a[i]);
printf("\n DESCENDING ORDER:\n"); for(i=n-1;i>=0;i--)
printf(" %d ",a[i]);
}