if(a[i]<=a[j])----->if(a[i]>=a[j])
You will get the output.
#include
#include
int main()
{
int i,j,temp;
int a[5]={-123,34,14,87,45};
printf("SORTING PROGRAM IN DESCENDING\n");
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if(a[i]>=a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
} for(i=0;i<5;i++)
printf("%d\n",a[i]);
getch();
}
No comments:
Post a Comment