Posts

Showing posts from November, 2019

Selection sort in C

C program for selection sort to sort numbers. This code implements selection sort algorithm to arrange numbers of an array in ascending order. With a little modification, it will arrange numbers in descending order. Selection sort algorithm implementation in C #include <stdio.h>   int  main ( ) {    int  array [ 100 ] ,  n ,  c ,  d ,  position ,  swap ;      printf ( "Enter number of elements \n " ) ;    scanf ( "%d" ,   & n ) ;      printf ( "Enter %d integers \n " ,  n ) ;      for   ( c  =   0 ;  c  <  n ;  c ++ )      scanf ( "%d" ,   & array [ c ] ) ;      for   ( c  =   0 ;  c  <   ( n  -   1 ) ;  c ++ )    {     position  =  c ;          fo...