Computer Science Homework Solutions
Problem
#166595

Write a program that reads real numbers from user into a vector of real numbers, and computes the average and maximum value of these numbers.

Write a program that declares a vector of real numbers and input values until a 0 is entered. Add the values to the vector by using push_back(), and compute both the average and the maximum value of the numbers. Output the average and the maximum.

Use the upcoming statements that intialize max to have the value -infinity. The first real number entered will become the new maximum.

double zero = 0.0;
//start max at -infinity
double max = -1.0/zero;



Solution Summary

Solution provides an imlementation, tested using g++ compiler, and also hints about another implementation for the given requirement.

Solution
What is this?
By OTA - Overall OTA Rating
Purchase Cost Now
$2.19 CAD (was ~$19.95)
Included in Download
  • Plain text response
  • Attached file(s):
    • 166595.cpp
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Data Structures + C++ STL - Give the value of v.size() after executing each of the following statements: (Be sure to include the code used to execute the statements. One program will be fine to execute all statements, no need to ...
  • Data Structures C++ - 10. What is the output of the following program segment? (Assume that screen is an ostream iterator initialized to the standard output device to output elements of the type int.) int list[5] = {2, ...
  • Need flow chart and pseudo-code for the following problem - Create a flowchart and pseudo-code for the following problem: You have a file containing the grades of students from Beginning Programming, along with the students' information. Your part of the pr ...
  • Array syntax, initialization, headers - 1. Give an example of an array that is initialized during declaration: 2. Write a method header that accepts an array as a parameter: 3. What is the result of the syntax: double a[ ], b;
  • C++ program that declares three single dimensional arrays. - See the attached file for more info.
Browse