Skip to content

Commit

Permalink
Merge pull request #12 from sumitrajpal29/main
Browse files Browse the repository at this point in the history
added Selection Sort program in C
  • Loading branch information
Zualemo-xo authored Oct 6, 2021
2 parents 59d984a + 64193c4 commit 68526cc
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions C/SelectionSort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <stdio.h>

int main()
{

int arr[] = {1,-22,10,300,8,7,55,-10};
int length=sizeof(arr)/sizeof(int);

for(int i=0;i<length-1;i++){

int min=i;

for(int j=i+1;j<length;j++){
if(arr[j]<arr[min])
min=j;

}


int temp=arr[i];
arr[i]=arr[min];
arr[min]=temp;

}


for(int i=0;i<length;i++){
printf("%d\n",arr[i]);
}

return 0;
}

0 comments on commit 68526cc

Please sign in to comment.