Computer Science, asked by garima23agarwal, 9 months ago

Write a program to store 10 numbers in array A[ ] and 5 numbers in array B[ ] and merge them into array C[ ].

Answers

Answered by rasmikrishnan123
1

#include<stdio.h>

void main()

{

int A[10], B[5], C[15];

int i, j=1;

printf("enter the numbers in to array A");

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

{

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

c[j]=A[i];

j++;

}

printf("enter the numbers in to array B");

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

{

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

c[j]=B[i];

j++;

}

printf("merged array");

for(j=1;j<=15;j++)

{

prjntf("%d", c[j]);

}

getch();

}

Answered by PHOENIX1243
0

Answer:

syntax for A:

int A[] = new int[10];

int B[] =  new int[5];

int C[] = new int[];

int fal  = A.length;        //determines length of firstArray  

int sal = B.length;   //determines length of secondArray  

int[] C = new int[fal + sal];  //resultant array of size first array and second array  

System.arraycopy(firstArray, 0, C, 0, fal);  

System.arraycopy(secondArray, 0, C, fal, sal);  

System.out.println(Arrays.toString(C));    //prints the resultant array  

Explanation:

Similar questions