#include<stdio.h>
int selectionsort(int n)
{
int i , num ,j , a[1000], pos , temp , k;
num = n;
printf("\n Enter the elements :- \t");
for(i =0; i<num; i++)
{
scanf("%d",&a[i]);
}
k=num-1;
for(i=0 ; i<k; i++)
{
pos =i;
for(j= i+1 ; j<num ; j++)
{
if(a[pos] > a[j])
{
pos = j;
}
}
if(pos != i)
{
temp = a[i];
a[i] = a[pos];
a[pos] = temp;
}
}
printf(" The Final Array After Sorting Is : \n");
for(i=0 ; i<num; i++)
{
printf("\t%d",a[i]);
}
return 0;
}
int main()
{
int n , x;
printf(" Enter the number of array elements : - \t");
scanf("%d",&n);
x = selectionsort(n);
return 0;
}
Follow
Me On Social Media :-
INSTA photography page :- https://www.instagram.com/photo_mania_hub/
Twitter link : - https://twitter.com/ApurbaKhanra199
Facebook page link (Crazy Coders) :-https://www.facebook.com/codercrazy/?modal=admin_todo_tour
Insta photography link :- https://www.instagram.com/photo_mania_hub/
Facebook link :- https://www.facebook.com/profile.php?id=100009747586288
For tech related videos visit my other website :- https://apurbatechinfo.blogspot.com/
0 Comments