Ask Question
27 December, 23:53

Compute the sum of the values in data_array, instead of using the sum () function. To do this, you must "accumulate" a result, which means that you first create a variable, called data_array_sum, to hold the accumulating result and initialize it to 0. Then loop through your array, updating the accumulating data_array_sum by adding each data_array value as you go: data_array_sum = data_array_sum + data_array (i);

+3
Answers (1)
  1. 28 December, 02:34
    0
    public class TestClock {

    public static void main (String[] args) {

    int [] data_array = {1,2,3,5,3,1,2,4,5,6,7,5,4,3};

    int data_array_sum = 0;

    for (int i=0; i
    data_array_sum = data_array_sum + data_array[i];

    System. out. println ("Acumulating sum is "+data_array_sum);

    }

    System. out. println ("Total sum is: "+data_array_sum);

    }

    }

    Explanation:

    Using Java programming language for this problem, we declare and initialize the array with this statement:

    int [] data_array = {1,2,3,5,3,1,2,4,5,6,7,5,4,3};

    Then created a variable to hold the sum values and initialize to zero:

    int data_array_sum = 0;

    Using a For Loop statement we iterate through the array and sum up the values.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Compute the sum of the values in data_array, instead of using the sum () function. To do this, you must "accumulate" a result, which means ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers