Page 472 - computer science (868) class 11
P. 472
76 for(int i=0;i<size;i++)
77 {
78 ar3[i]=a[i]+b[i];
79 }
80
81 System.out.println("the sum of the 2 arrays is:");
82 printArray(ar3);
83 return ar3;
84 }
85 //function for printing the array
86
87 public static void printArray(int arr[])
88 {
89 int n = arr.length;
90 for (int i=0; i<n; ++i)
91 System.out.print(arr[i] + " ");
92 System.out.println();
93 }
94 //main method
95
96 public static void main(String args[])
97 {
98 Scanner sc= new Scanner(System.in);
99 System.out.println("enter the size of the array");
100 int size=sc.nextInt();
101 int ar1[]=new int[size];
102 int ar2[]=new int[size];
103 //input of array
104 System.out.println("enter elements in the 1st array");
105 for(int i=0;i<size;i++)
106 {
107 ar1[i]=sc.nextInt();
108 }
109 System.out.println("enter elements in the 2nd array");
470470 Touchpad Computer Science-XI

