Computer Science, asked by pratishmoses, 8 months ago

Write a program in java to input ten numbers each in two different arrays and find the sum of the two arrays.

Answers

Answered by rg71713
1

Answer:

In this tutorial we will see how to sum up all the elements of an array.

Program 1: No user interaction

/**

* @author: BeginnersBook.com

* @description: Get sum of array elements

*/

class SumOfArray{

public static void main(String args[]){

int[] array = {10, 20, 30, 40, 50, 10};

int sum = 0;

//Advanced for loop

for( int num : array) {

sum = sum+num;

}

System.out.println("Sum of array elements is:"+sum);

}

}

Output:

Sum of array elements is:160

Similar questions