Write an algorithm or source code for merge sort using c language?

#include<stdio.h>

#include<conio.h>

void mergesort(int[],int ,int);

void merge(int[],int,int,int);

void main()

{

int a[10] = {10,9,7,10,23,63,29,11,02,83};

int i;

mergesort(a,0,9);

printf(“printing the sorted elements”);

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

{

printf(“\n printing the sorted elements’);

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

{

printf(“\n %d\n”,a[i]);

}

 

}

void mergesort(int a[],int beg,int end)

{

int mid;

if(beg<end)

{

mid= (beg+end)/2;

mergesort(a,beg,mid);

mergesort(a,mid+1,end);

merge(a,beg,mid,end);

 

 

}

 

}

void merge(int a[],int beg,int mid,int end)

{

int i =beg,j=mid+1;,k,index = beg;

int temp[10];

while(i<= mid && j<=end)

{

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

{

temp[index] = a[i];

i = i+1;

}

else

{

temp[index]= a[j];

j=j+1;

}

index++;

 

 

}

if(i> mid)

{

while(j<= end)

{

temp[index] = a[j];

index++;

j++;

 

}

}

else

{

while(i< =mid)

{

temp[index] = a[i];

index++;

i++;

 

}

}

k=beg;

while(k<index)

{

a[k]= temp[k];

k++;

 

}

}

 

getch();

}

output:———————–

printing the sorted elements:-

02,07,9,10,10,11,23,29,63,83

 

Write an algorithm for the insertion sort using C?

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,k,temp;

int a[10] = {10,9,7,101,23,44,12,78,34,23};

clrscr();

printf(“\n printing sorted elemts\n”);

for(k=1;k<10;k++)

{

temp = a[k];

j=k-1;

while(j>=0 && temp <=a[j])

{

a[j+1] =a[j];

j=j-1;

}

a[j+1] = temp;

 

}

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

{

printf(“\n %d\n”,a[i]);

 

 

}

getch();

}

output:—–

printing sorted elements:-

7,9,10,12,23,2,3,34,44,78,101

thank you just write and implement good luck:-