Write a c program to print the insertion sort algorithm with example

Write a c program to print the insertion sort algorithm with example. This program is basically sorting program using the insertion sorting. The values will be initialized after the current values process has been done in insertion sorting in c programming language

#include<stdio.h>
int main()
{
int i, j, count, temp, num[25];
printf("How many nums ");
scanf("%d",&count);
printf("Enter %d elements", count);
for(i=0;i<count;i++)
scanf("%d",&num[i]);
for(i=1;i<count;i++)
{
temp=num[i];
j=i-1;
while((temp<num[j])&&(j>=0))
{
num[j+1]=num[j];
j=j-1;
}
num[j+1]=temp;
}
printf("After sorting");
for(i=0;i<count;i++)
printf(" %d",num[i]);
return 0;
}

 

Output:

How many nums

3

Enter 3 elements

2334 65 1

After sorting 1 65 2334