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
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
Computer Science,
4 months ago
Social Sciences,
4 months ago
English,
4 months ago
Math,
8 months ago
Chemistry,
11 months ago
Biology,
11 months ago