/*
This is a basic program of Insertion sort.
Author: Afiz
Date:
*/
#include<stdio.h>
main()
{
int a[5]={9,7,4,8,1};// array with 5 elements.
int out,in,min,i;// local variable declarations
for(out=1;out<5;out++) // outer loop
{
temp = a[out];
in =out;
while(in>0 && a[in-1]>=temp) // inner loop
{
a[in]=a[in-1];
--in;
}
a[in]=temp;
}
//printing array ..
for(i=0;i<5;i++)
{
printf("%d\n",a[i]); //
}
}
0 Comments