Respuesta :
Answer:
#include <stdio.h>
#include <stdlib.h>
//Define the main function.
int main()
{
//Define the variables.
int nArr1=0,nArr2=0;
//Prompt the user to enter the size of the array.
printf("Enter the size of first array :\n");
scanf("%d",&nArr1);
printf("Enter the size of second array :\n");
scanf("%d",&nArr2);
//Define the array and loop variable.
int A[nArr1+nArr2], B[nArr2], aiter=0,biter=0,a=0;
//Prompt th user to enter arary A
printf("Enter Array A :\n");
for(aiter=0;aiter<nArr1;aiter++)
scanf("%d",&A[aiter]);
//Prompt th user to enter arary B
printf("Enter Array B :\n");
for(biter=0;biter<nArr2;biter++)
scanf("%d",&B[biter]);
//Merge the arrays in to array A.
for(int i=0;i<nArr2;i++)
A[nArr1+i]=B[i];
//Sort the merged array.
for (aiter = 0; aiter < nArr1+nArr2; ++aiter)
{
for (biter = aiter + 1; biter < nArr1+nArr2; ++biter)
{
if (A[aiter] >= A[biter])
{
a = A[aiter];
A[aiter] = A[biter];
A[biter] = a;
}
}
}
//Display the result.
printf("\nThe final Array A after merge is:\n");
for(aiter=0;aiter<nArr1+nArr2;aiter++)
printf("%d ",A[aiter]);
printf("\n");
//Return the value 0.
return 0;
}
Step-by-step explanation: