Business Studies, asked by rushabhshinde30, 5 months ago

. Write a program for the sum of
given Array​

Answers

Answered by ItzZiddiBachi2045
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