/*PROGRAM TO SORT THE ELEMENTS OF AN ARRAY IN ASCENDING ORDER*/

 

#include<stdio.h>

#include<conio.h>

void main()

{

int a[10],i,n,j,t,k;

clrscr();

printf(“\nSize of Matrix: “);

scanf(“%d”,&n);

 

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

{

printf(“Enter element %d: “,i+1);

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

}

 

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

{

for(j=0;j<n-i-1;j++)

{

if(a[j]>a[j+1])

{

t=a[j];

a[j]=a[j+1];

a[j+1]=t;

}

}

}

 

printf(“\n Sorted elements are: \n”);

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

printf(“\t%d”,a[i]);

 

getch();

}

157 total views, 2 views today

Get Free Email Updates..!
Join us for FREE to get instant email updates..! GobsInfo- Everything Unlimited
We hate spam. Your email address will not be sold or shared with anyone else.