From e05066d3cffcfca41b6b4d25ac08d051926c6801 Mon Sep 17 00:00:00 2001 From: Jasneet410 <71989615+Jasneet410@users.noreply.github.com> Date: Fri, 2 Oct 2020 16:19:29 +0530 Subject: [PATCH] Selection_Sort Add a file for Selection sort in C language --- C/Selection_Sort | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 C/Selection_Sort diff --git a/C/Selection_Sort b/C/Selection_Sort new file mode 100644 index 0000000..a41b1cf --- /dev/null +++ b/C/Selection_Sort @@ -0,0 +1,34 @@ +#include +int main(){ + /* Here i & j for loop counters, temp for swapping, + * count for total number of elements, number[] to + * store the input numbers in array. You can increase + * or decrease the size of number array as per requirement + */ + int i, j, count, temp, number[25]; + + printf("Enter the number of elements : "); + scanf("%d",&count); + + printf("Enter %d elements: ", count); + // Loop to get the elements stored in array + for(i=0;inumber[j]){ + temp=number[i]; + number[i]=number[j]; + number[j]=temp; + } + } + } + + printf("Sorted elements: "); + for(i=0;i