Displaying Source Code(s)
|
|
Program to sort an array in decending order.
--------------------------------------------------------------------------------
Description : Not Specified
#include <stdio.h>
#include <math.h>
void main()
{
int i[100],j[100],temp[100];
int a,b=1,c,i1=2,k,b2=0;
printf("ENTER NUMBER OF DATA (MAXIMUM 100):");
scanf("%d",&k);
printf("ENTER DATA (IN INTEGER):<BR>);
for(a=0;a<k;a++)
{
printf("k=[%d] ",a+1);
scanf("%d",&i[a]);
}
for(a=0,b=1;a<k,b<k;a++,b++)
{
if((i[b]-i[a])>0)
{
temp[a]=i[b];
temp[b]=i[a];
i[a]=temp[a];
i[b]=temp[b];
}
for(c=i1;c<k;c++)
{
if((i[c]-i[a])>0)
{
temp[a]=i[c];
temp[c]=i[a];
i[a]=temp[a];
i[c]=temp[c];
}
}
i1++;
}
printf("
YOUR ARRAY IN DECENDING ORDER IS AS FOLLOWS:
YOUR
ARRAY[%d]= ",k);
for(b2=0;b2<k;b2++)
{
printf("%d ",i[b2]);
}
printf("
***THANK YOU FOR USING THIS PROGRAM***<BR>);
}
|
|
|