From 2f5dd5734cefd7cf47f04b4e40976132bdb34f74 Mon Sep 17 00:00:00 2001 From: ankit-1912 <56951968+ankit-1912@users.noreply.github.com> Date: Tue, 27 Oct 2020 20:23:06 +0530 Subject: [PATCH] Selection_sort.c Arranging array elements using selection sort --- C/Selection_sort.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 C/Selection_sort.c diff --git a/C/Selection_sort.c b/C/Selection_sort.c new file mode 100644 index 0000000..ead2366 --- /dev/null +++ b/C/Selection_sort.c @@ -0,0 +1,29 @@ +// C Program to arrange the array using selection sort + +#include +#include +int main() +{ + int n,i,j,min=0,temp=0; + printf("Enter the length of an array: "); + scanf("%d",&n); + int arr[n]; + printf("Enter the values: "); + for(i=0;iarr[j]) + min=j; + } + temp=arr[min]; + arr[min]=arr[i]; + arr[i]=temp; + } + printf("The arranged array is: "); + for(i=0;i