The document contains a Java program that merges two integer arrays, A and B, into a third array C. The program prompts the user to input the sizes and elements of arrays A and B, then combines them into array C. Finally, it prints the elements of array C, which contains all the data from both A and B.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
0 views
ArrayMerge
The document contains a Java program that merges two integer arrays, A and B, into a third array C. The program prompts the user to input the sizes and elements of arrays A and B, then combines them into array C. Finally, it prints the elements of array C, which contains all the data from both A and B.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
/**
* Suppose A, B, C are arrays of integers of sizes m, n, m + n respectively.
* Give a program to produce a third array C, containing all the data of array A and B. * * @author (your name) * @version (a version number or a date) */ import java.util.Scanner;
public class ArrayMerge
{ public static void main(String args[]){ Scanner in = new Scanner(System.in); System.out.print("Enter size m : "); int m = in.nextInt(); int A[] = new int[m];
System.out.print("Enter size n : ");
int n = in.nextInt(); int B[] = new int[n];
int C[] = new int[m + n];
System.out.println("Enter elements of array A:");
for(int i = 0; i < m; i++) { A[i] = in.nextInt(); }
System.out.println("Enter elements of array B:");
for(int i = 0; i < n; i++) { B[i] = in.nextInt(); }