Answer:
Following are the code:
Code:
total = 0; //assign value to total variable.
for (int i=0; i<x.length; i++) //for loop
{
total=total+x[i]; //add all array elements in total variable.
}
Explanation:
In the following question, it is defined that x and total is variable. Where variable x is an integer type array and total is an integer variable. we define some code for calculating the sum of the array element. In the above code, we use for loop that calculates sum of array elements that can be described as: