Ask Question
9 August, 13:55

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);

+4
Answers (1)
  1. 9 August, 14:16
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers