Answers for "addition of two arrays"

0

addition of two arrays

int[] a = {10, 20 30, 40}; int[] b = {25, 50, 75, 100, 125}; int[] sum = new int[b.length];  for (int i = 0; i <= b.length; i++){ 	sum[i] = 0;	 		/*initialize each of the sum values as zeroes, because that's 		what we usually start with*/ 		 	if (i > b.length){  		/*if one array is longer than the other, just add zero the  		remaining elements in the largest array*/ 		sum[i] = b[i] + 0; 	else{ 		sum[i] = a[i] + b[i]; 	} } 
Posted by: Guest on February-03-2021

Code answers related to "addition of two arrays"

Browse Popular Code Answers by Language