Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here i s what i have s o far having trouble getting i t t o tell m e the max value number o f

Here is what i have so far having trouble getting itto tell me the max value number of the I values
Write a small program that accepts a user-given number n and then reads in n more integers that the user gives and computes the average as well as the maximum of the n integers.
#include
using namespace std;
int main()
{
//variable declaration
int n, i, temp, max;
//As we are dealing with the sum, so initializing with 0.
double sum =0;
//As the average of integers can be a fractional value.
double average =0;
//taking input from the command line (user)
cout <<" Enter the number of integers you want to find the average of : ";
cin >> n;
cout <<"
";
//taking n numbers as input from the user and adding them to find the final sum
for (i =0; i < n; i++)
{
cout << "Enter number" << i +1<<" : ";
cin >> temp;
//add each number to the sum of all the previous numbers to find the final sum
sum += temp;
}
//Finding the average of the entered numbers (atleast one of the varialbe on the RHS has to be double for average to be double)
average = sum / n;
cout <<"
The Sum of the "<< n <<" numbers entered by the user is : "<< sum << endl;
cout <<"
The Average of the "<< n <<" numbers entered by the user is : "<< average << endl;
cout <<"
";
return 0;
}

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_2

Step: 3

blur-text-image_3

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

Visualizing Health And Healthcare Data Creating Clear And Compelling Visualizations To See How Youre Doing

Authors: Katherine Rowell ,Lindsay Betzendahl ,Cambria Brown

1st Edition

1119680883, 978-1119680888

More Books

Students also viewed these Databases questions

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago

Question

2. What is the impact of information systems on organizations?

Answered: 1 week ago

Question

Evaluate the impact of technology on HR employee services.

Answered: 1 week ago