Google Search

Custom Search

Sunday, February 14, 2010

Sort an Array in Decending Order

#include
#include
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):
");
for(a=0;a
{
printf("k=[%d] ",a+1);
scanf("%d",&i[a]);
}
for(a=0,b=1;a
{
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
{
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
{
printf("%d ",i[b2]);
}
printf("

***THANK YOU FOR USING THIS PROGRAM***
");
}

No comments: