Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Sunday, September 4, 2022

C program to Sort an array of input ten elements in an descending order

C program to Sort an array of input ten elements in an descending order 


#include<stdio.h>

#include<conio.h>

main()

{

int a[10], i, j, temp;

printf("Enter number\n");

for (i=0;i<=9;i++)

{

scanf("%d",&a[i]);

}

for(i=0;i<=9;i++)

{

for(j=i+1;j<=9;j++)

{

if(a[i]<a[j])

{

temp=a[i];

a[i]=a[j];

a[j]=temp;

}

}

}

printf("\n Sorted numbers (Descending)\n");

for(i=0;i<=9;i++)

printf("%d\n",a[i]);

getch();

}


Output:




No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages