โ Back to Loops
Question 27
While Loop: Sum an Array
While Loop: Sum an Array
Use a while loop to find the total of all numbers in the array. Array: [4, 8, 2, 6] Expected output: Total: 20 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
Topics:
LoopsArrays
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.