here you find the best simplest implement of programs

code_world

love programing and watch my all easy implement of program hope you like it

Wednesday, 3 May 2017

insertion sort using c


                 INSERTION SORT USING C


#include<stdio.h>
#include<conio.h>
#define size 5
void main()
{
 int i,j,temp,a[size];
 clrscr();
 printf("enter the element");
 for(i=0;i<size;i++)
 scanf("%d",&a[i]);
for(i=0;i<size;i++)
{
 j=i;
 while(j>0 && (a[j] < a[j-1]))
 {
  temp = a[j];
  a[j] = a[j-1];
  a[j-1] = temp;
   j--;
  }
 }
  for(i=0;i<size;i++)
  printf("\nsorted element%d",a[i]);
  getch();
 }

Share:

Related Posts:

0 comments:

Post a Comment