DECREASING ORDER*/
#include
#include
void main()
{
int a[20],i,j,n,e;
clrscr();
printf("\n\nENTER THE NO OF ELEMENTS=");
scanf("%d",&n);
printf("\n\nENTER THE ELEMENTS IN AN ARRAY=");
for(i=0;i < n ; i++)
{
scanf("%d",&a[i]);
printf("\n\n");
}
for(i=0;i < n ; i++)
{
for(j=0;j < n ;j++)
if (a[j]< a[j+1])
{
e=a[j+1];
a[j+1]=a[j];
a[j]=e;
} }
printf("\n\nAFTER SORTING VALUES ARE=\n\n");
for(i=0;i < n;i++)
{
printf("\n\n");
printf("%d",a[i]);
}
getch();
}
/******************************************************************
OUTPUT
******************************************************************
ENTER THE NO OF ELEMENTS=6
ENTER THE ELEMENTS IN AN ARRAY=2
1
3
6
5
7
AFTER SORTING VALUES ARE=
7
6
5
3
2
1
*/
No comments:
Post a Comment