CJCoding With Joseph
15per day

Sum All Elements

An array called nums has already been created for you with the values {10, 20, 30, 40, 50}. A variable called sum has also been initialized to 0.

Your task is to use the for loop to add up all the elements in the array, then print the total sum.

Inside the loop, add the current element to sum using: sum += nums[i]; (this is the same as sum = sum + nums[i]).

After the loop finishes, print the result in this exact format:
Sum: 150

Expected Output:

Sum: 150
Topics:
Arrays
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.