CJCoding With Joseph
15free / daySign inCreate account

While Loop: Sum an Array

Use a while loop to find the total of all numbers in the array.

Array:
[4, 8, 2, 6]

Steps:
1. Use the provided numbers array
2. Create index and total variables
3. Use a while loop to add each number to total
4. Print the total

Expected Output:

Total: 20

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
LoopsArrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.