If you create a Console application using Visual Studio C++ 2010, you should get something like that:
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
int _tmain(int argc, _TCHAR* argv[])
{
int i,j,p,q,x[50],y[50];
void merge(int x[],int y[],int p,int q);
printf("Enter the length of the 1st sorted array :");
scanf("%d",&p);
printf("Enter the sorted values of the 1st array :");
for(i=0;i<=p;i++)
scanf("%d",&x[i]);
printf("Enter the sorted values of the 2nd array :");
scanf("%d",&q);
printf("Enter the sorted values of the 2nd array :");
for(j=0;j<=q;j++) scanf("%d",&y[j]);
merge(x,y,p,q);
getch();
}
void merge(int x[],int y[],int p,int q)
{
int i=0,j=0,k=0,z[100];
while(i)
{
if(x[i]<y[j])
{
z[k]=x[i];
i++;
k++;
}
else if(x[i]>y[j])
{
z[k]=y[j];
j++;
k++;
}
else
{
z[k]=x[i];
i++;
j++;
k++;
}
}
while(i<p)
{
z[k]=x[i];
i++;
k++;
}
while(j<q)
{
z[k]=y[j];
j++;
k++;
}
printf("The new merged array is :");
for(i=0;i<k;i++)
{
printf("%d",z[i]);
}
return;
}