Array Descending Order || BCA THERAPY
INPUTS
// Array Descending Order //
#include <stdio.h>
main()
{
int i, j, a, n, arr[5];
printf("Enter the value of N \n");
scanf("%d", &n);
printf("Enter the numbers \n");
for (i =0;i<n;i++)
scanf("%d",&arr[i]);
for (i=0;i<n;i++)
{
for (j=i+1;j<n;j++)
{
if (arr[i]<arr[j])
{
a =arr[i];
arr[i] = arr[j];
arr[j] = a;
}
}
}
printf("ascending order\n");
for (i=0;i<n;i++)
printf("%d\n",arr[i]);
}
Comments
Post a Comment