14,644,624 members
Rate this:
See more:
A FOR loop that will cycle through each of these elements and add them together ..displaying a sentence that will notify the user of the total value of the elements in the array with the end of the algorithm...

sequence: 2,8,18,32,50,72,98,128,168,200
Posted
Updated 7-May-14 21:35pm
v3
DamithSL 8-May-14 3:14am

in which programming language?

No language, not platform, nothing. What's the point asking such "question", and what's the use?
—SA

Rate this:

## Solution 1

Try:
```int[] data = new int[] {2,8,18,32,50,72,98,128,168,200};
int total = 0;
for (int index = 0; index < data.Length; index++)
{
total += data[index];
}
Console.WriteLine(total);```

But a better way:
```int[] data = new int[] {2,8,18,32,50,72,98,128,168,200};
Console.WriteLine(data.Sum(x => x));```
Rate this:

## Solution 2

You need to check out the documentation of your favourite language, in order to actually coding it.
A simple approach would be:
• Initialize the `sum` to `0`.
• Iterate over the `10` items, that is make a `FOR` loop with an index, say `i`, ranging from `0` to `9` (or `1` to `10`, depending on the programming language).
• At every iteration update the sum, someting like `sum = sum + a[i]`.