C Program For Insertion Sort

/*Insertion Sort*/


#include<stdio.h>
#include<conio.h>
void main(void)
{
int i=0,j,k,val,a[10];
clrscr();
printf("Enter the value");
scanf("%d",&val);
 while(val!=-9999)
 {
 k=i-1;
  while((val<a[k])&&(k>=0))
  {
  a[k+1]=a[k];
  k--;
  }
 a[k+1]=val;
 printf("Array after the inserting the value is\n");
  for(j=0;j<=i;j++)
  {
  printf("a[%d]=%d\n",j,a[j]);
  }
 printf("Enter the value\n");
 scanf("%d",&val);
 i++;
 }
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment