print the sum of each element in an array
Answers
Answered by
0
Answer:
print the sum of each element in an array
Answered by
2
Answer:
public class SumOfArray {
public static void main(String[] args) {
//Initialize array.
int [] arr = new int [] {1, 2, 3, 4, 5};
int sum = 0;
//Loop through the array to calculate sum of elements.
for (int i = 0; i < arr.length; i++) {
sum = sum + arr[i];
Similar questions