/* To arrange the series in descending order */
#include<stdio.h>
#include<math.h>
int main()
{
int i, j, n;
float A[50], t;
printf("Input the no. of data:");
scanf("%d",&n);
printf("\nEnter the data:\n");
for(i=0;i<n;i++)
scanf("%f",&A[i]);
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(A[i]>A[j])
{
t=A[i];
A[i]=A[j];
A[j]=t;
}
}
}
printf("\nSorted array in descending order is:\n");
for(i=0;i<n;i++)
printf(" %f\n",A[i]);
return(0);
}
#include<stdio.h>
#include<math.h>
int main()
{
int i, j, n;
float A[50], t;
printf("Input the no. of data:");
scanf("%d",&n);
printf("\nEnter the data:\n");
for(i=0;i<n;i++)
scanf("%f",&A[i]);
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(A[i]>A[j])
{
t=A[i];
A[i]=A[j];
A[j]=t;
}
}
}
printf("\nSorted array in descending order is:\n");
for(i=0;i<n;i++)
printf(" %f\n",A[i]);
return(0);
}
Comments
Post a Comment