Five Numbers from Input
mediumQuestion 536Write a program that reads exactly five integers from standard input (separated by spaces or newlines) into an array<int, 5>, then prints their sum and their average.
Print two lines: the word Sum:, a space and the sum as an integer, then the word Average:, a space and the average (sum divided by 5.0) with exactly one decimal place using fixed and setprecision(1) from <iomanip>.
Example input: 1 2 3 4 5
The output for that input is shown in Expected Output.
Expected output
Sum: 15 Average: 3.0 Sum: 23 Average: 4.6
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
STL Containersstd::array
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.