C program for Selection Sort.

/*Selection Sort*/#include<stdio.h>#include<conio.h>int main(){    int i,j,k,x,temp;int a[10]={};printf("Please Enter Numbers To Sort MAX:10 nn");for(i=0; i<=9; i++){         scanf("%d",&a[i]);}printf("n Unsorted list is ....n"); for(x=0; x<=9; x++)        {          printf("%4d",a[x]);          }printf("nn");for(i=0; i<10-1; i++ ){         j=i;         for(k=j+1; k<10; k++)                    if(a[k]<a[j])                    j=k;    if(i != j)         {            temp=a[i];            a[i]=a[j];            a[j]=temp;            }        printf("Iteration Number %d :: >>",i+1); for(x=0; x<=9; x++)        {          printf("%6d",a[x]);          }          printf("n");}getch();}

 

Comments

Popular posts from this blog

MATLAB code for Circular Convolution using Matrix method

Positive number pipe in angular 2+