You are on page 1of 4

Date :

Expeimesl Noit
Am-To witeo proqram tor celechon cot

Theory' qeneally sd
Selechion sot is o corbing algoiHam small
fles wth arge eords and kes.
worce Ben uncetan inserhe sor
re

AlhaghF petoMs c0ok

TRbniaue
Gnsideranayowithoelements
the smallest value in any ploce itis frst
posiben then tnd the secand smallest valve n sub-ongy
ond placetio cecond posihon fepesd onbl entite anray is Satd.
E-399I
al5) a[6] a
PADS POS alo] al) al2] al3al 2 18
39 9l45 22
42 39
2 18 90 22
45 39
27
t 27 39 90 22
72
5 18 39
t2 40
18 2 39

sersihveb m
Gmplehy Selechcn sot is not datto celect soallest pass
n-j om pariciens will be needed
elenent
Thus, the no.ot Gnpoicicns needed o soyt aiay wit
elementseln-)+ ln-2)+..t2+
2 2

Page No.
B

<for Ge0,1 Kn:itt)

Disploy sorled
elements

Shop
Date:

Agoithm- main ():


Stepl -star
Dedare n , YClo) as
")
'Enter sl2e of aIay
Stp3Display "Enter
Sepy- Read n
StepS- DispleyEn ter clemenks of aitay
Stpb Iaibalize je0
to step 9
Step &- Read onOy element lars,n)
Stp9- all selechon sol
Selechen-Sot (os, n)
Stpl-Ctait
Ctep2- Decdore yjmin, temp os ntgc
Skp3 Inibali2e
to stpll
Sep b.- Tf izn- hen go
StpS- Colalate
lo
Step 7 If jzn then qo t step
alulake: temp zanl
Clepi- Tf lonll<oylmin).
arr Cmio]= temp
Jncremen t
Stp?
Steplo Tnrement
Stepll:-Ioihalze j o
qo to skp y
Stepl2 :- f jzn then elements
Stepl3:- Display sorkd
Step ly- Stop.
have sucesstully implenentd o ploqlam
Conclusien Honce we
selechen Sort
for
Page No. 2
#include<stdio,h>
#include<time. h>
#include<math. h>
#include<stdlib.h>

int main()

int A[20],i,j,n, k;
int temp, Min ;
printf( "Enter Number of Elements:- ->");
scanf("%d", &n) ;
for (i=0;i<n;it+)
{ printf("\nEnter A[%d]:-->",i+1);
scanf("i%d", &A[i]);
for(i=0;isn-1;i++)
Min=i;
for(j=i+1;j<n;j++)
if (A[j]<A[Min])
Min=j;
}
temp=A[i];
A[i]=A[Min];
A[Min]=temp;
printf("\nOutput After Pass %d: - ->",i+1):
for (k=0;k<n;k++)
printf("%d",A[k] );

return 0;

**OUTPUT*

Enter Number of Elements:-->5

Enter A[1]:-->44
Enter A[2]: -->>88
Enter A[3]: -->98
Enter A[4]:-->25
Enter A[5]: -->11
Output After Pass 1: -->1188982544
Output After Pass 2:-->1125988844
Output After Pass 3:-->1125448898
Output After Pass 4: -->1125448898

You might also like