. Write a program for the sum of
given Array
Answers
Answered by
1
Answer:
JAVA
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
English,
2 months ago
Social Sciences,
2 months ago
Social Sciences,
2 months ago
Biology,
5 months ago
Math,
5 months ago
Art,
10 months ago
English,
10 months ago
English,
10 months ago