176k views
5 votes
Q) write a code that reads a given array and calculates the SUM of its elements.

1 Answer

4 votes

Answer:

See the explanation below.

Step-by-step explanation:

If don't know which language you are using, but the basic pseudo code for this problem will be:

variable sum = 0;

for ( i = 0; i < array.length; i ++) {

sum += array[i];

}

print(sum);

Best Regard!

User Marc ABOUCHACRA
by
3.9k points