Sum All Elements
easyQuestion 96An 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 the exact format shown in Expected Output.
Expected output
Sum: 150= newline. No newline after the last line.
Hints2 available
Sign in to use hintsTopics
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.