FaltuTech.Club : Fane of Advanced Logical Thriving Utopian Technical Club

Selection Sort Using C (C-code)



#include 
#include 
void selection_sort(int arr[],int n){       // function to sort with selection algorithm
 int i,j,smallest,position,start=1,temp;  
 for (i=0;iarr[j])                {   // check if any other number is smaller
    smallest=arr[j];
    position=j;
    }
}  if(arr[i]!=smallest)             {   // if smallest value changed than swap
  temp=arr[i];
  arr[i]=smallest;
  arr[position]=temp;
  }
  start=start+1;
  }
  }
  void print_array(int arr[],int n) {    //function to print a n size array
  int i;
  for(i=0;i