Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

Which political behavior do I want to improve the most?

Answered: 1 week ago