Ask Question
22 March, 17:41

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. 22 March, 17:59
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers