Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write a C++ to calculate the sum and average of a sequence of integers. (Only use while-loop) The program asks the user to input
Please write a C++ to calculate the sum and average of a sequence of integers. (Only use while-loop)
The program asks the user to input the number of integers first (you don't need to validate the input). Write a loop that reads each integer and adds it to sum on each iteration.
You also need to calculate the average after the loop. Display the results with 4 digits after the decimal point.
Here is a sample run:
Enter the number of values: 3
Enter 3 integers: 25 56 38
The sum of integers is 119
The average of integers is 39.6667
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started