Java Programming

Two Array Sum

Java programming example for sum of two array and store on 3rd array

9/7/2021
0 views
two-array-sum.javaJava
import java.io.*;

class twoarraysum {
	public static void main(String args[ ]) {

		/* Declaration of integer type array and initialize with 10 values */
		int array1[ ] = {1,2,3,4,5,6,7,8,9,10};
		int array2[ ] = {10,9,8,7,6,5,4,3,2,1};

		/* Declaration of integer type array */
		int ans[ ] = new int[10];
		for(int i = 0; i < 10; i++)
			ans[i] = array1[i] + array2[i];
		System.out.println("Sum of two Array:");
		for(int i = 0; i < 10; i++)
			System.out.println(ans[i]);
	}
}



/* Output */
Sum of two Array:
11
11
11
11
11
11
11
11
11
11
Sum of Two arrayArray sumJava tutorial

Loading comments...

Related Examples

Deliver breaking news, insightful commentary, and exclusive reports.

Targeting readers who rely on our platform to stay ahead of the curve.

Contact Us: benzingaheadlines@gmail.com