Page 399 - CA_Blue( J )_Class10
P. 399
Enter a number : 45
Enter a number : 50
Enter a position to delete the number: 4
5 10 15 20 30 35 40 45 50
Program 17 To merge two array elements and display the new array.
1 import java.util.*;
2 class merge_logic
3 {
4 public static void main()
5 {
6 Scanner sc= new Scanner(System.in);
7 int l1,l2,l3,i,j;
8 System.out.println("Enter length of 1st array");
9 l1=sc.nextInt();
10 System.out.println("Enter length of 2nd array");
11 l2=sc.nextInt();
12 System.out.println("Length of merged array");
13 l3=l1+l2;
14 int ar1[]=new int[l1];
15 int ar2[]=new int[l2];
16 int ar3[]=new int[l3];
17 for (i=0; i<l1; i++)
18 {
19 System.out.print("Enter element in 1st array : ");
20 ar1[i] =sc.nextInt();
21 }
22 for (i=0; i<l2; i++)
23 {
24 System.out.print("Enter element in 2nd array : ");
25 ar2[i] =sc.nextInt();
26 }
27 for (i=0; i<l1; i++)
28 { ar3[i]=ar1[i]; }
29 j=l1;
397
Arrays 397

