I have the following question:
Write a program with a function named "merge" that copies the data integers of one array into a larger sized array, and then copies the data integers of the second array into the larger array just after the contents of the first array
There is something wrong with my function
If I entered {1,2} for array 1 and {3,4} for array 2
then the output is 1 2 -57574 -658675
It should be 1 2 3 4
void merge (int a[], int n, int b[],int m) {
int c[100];
int x=n+m ; //size of merge aray c[]
for(int i = 0; i < n; i++)
c[i]=a[i];
for(int j = n ; j < x ; j++)
c[j] = b[j];
cout<<endl<<endl;
for(int k = 0; k < x; k++)
cout<<c[k]<<" ";
}
b[j]?jis a big number. you need to modify the index for the second copying pass.