← Back to Arrays
Question 119
Multiply All Elements Together
Multiply All Elements Together
An array called nums has already been created for you with the values {2, 3, 4, 5}.
Your task is to multiply all the elements together and print the product.
This is similar to summing, but instead of adding each element to a running total, you multiply. The key difference is that you must initialize your result variable to 1, not 0. If you start at 0, multiplying anything by 0 will always give 0.
2 × 3 × 4 × 5 = 120
Print the result in the exact format shown in Expected Output.Expected Output:
Product: 120= newline. No newline after the last line.
Hints4 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.