Solved

# Urgent Program require

Posted on 2000-02-19

Could you give me the program for Insertion sort and Merge Sort??? It is urgent.

the following is the program for insertion sort that I'd tried out please debug it.

#include<stdio.h>

void main()

{

int x[20],n,i=0,y,j=0;

clrscr();

printf("The no of numbers in the sorted list");

scanf("%d",&n);

//x[]=x[n];

for(i=0;i<n;i++)

{

printf("Enter a number");

scanf("%d",&x[i]);

}

for(i=1;i<n;i++)

{

y=x[i];

for(j=i-1;j>=0;j--)

{

if(x[i]<x[j])

{

//x[j+1]=x[j];

//x[j+1]=y;

x[i]=x[j];

x[j]=y;

}

//break;

}

}

for(i=0;i<=n;i++)

printf("\n%d",x[i]);

}