Skip to main content

PROGRAM TO SORT AN ARRAY OF 10 ELEMENTS USING SELECTION SORT


#include<stdio.h>
#include<conio.h>
void main()
{
long int i,j,small,tmp,pos,a[10];
clrscr();
printf("enter nos.\n");
for(i=0;i<10;i++)
scanf("%ld",&a[i]);

for(i=0;i<10;i++)
{ small=a[i];
  pos=i;
for(j=i+1;j<10;j++)
 {
if(a[j]<small)
  {
  small=a[j];
  pos=j;
 }
 }
tmp=a[i];
a[i]=a[pos];
a[pos]=tmp;
}
printf("sorted array is -->\n");
for( i=0;i<10;i++)
printf("%ld\n",a[i]);
getch();
}

SIMPLE PROGRAMS
FUNCTIONS


NUMBERS


STRINGS AND CHARACTERS

Comments

Popular posts from this blog

unix commands