From fe67374edceb352cb85bf3a75d2b643a6b937511 Mon Sep 17 00:00:00 2001 From: harshitbansal373 Date: Sun, 6 Oct 2019 10:52:39 +0530 Subject: [PATCH] selection sort --- sorting/selection_sorting.c | 66 +++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/sorting/selection_sorting.c b/sorting/selection_sorting.c index a40df9c..326437e 100644 --- a/sorting/selection_sorting.c +++ b/sorting/selection_sorting.c @@ -1,34 +1,36 @@ #include -#include -void main() -{ -clrscr(); -int a[20],i,j,size,temp,loc,min; -printf("enter array size"); -scanf("%d",&size); -printf("enter array element"); -for(i=0;imin) - { - min=a[j]; - loc=j; - } - } - temp=a[i]; - a[i]=a[loc]; - a[loc]=temp; +int main(){ + int i,n,j,min,loc,temp,value; + printf("enter number of number elements in array\n"); + scanf("%d",&n); + int arr[n]; + printf("\nenter array elements"); + for(i=0;iarr[j]){ + min=arr[j]; + loc=j; + } + } + temp=arr[i]; + arr[i]=arr[loc]; + arr[loc]=temp; + } + + printf("\nselection sorted array\n"); + for(i=0;i