Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//program 4.6.3 below int main() { vector temps; // temperatures for (double temp; cin>>temp; ) // read into temp temps.push_back(temp); // put temp into vector

image text in transcribed

//program 4.6.3 below

int main()

{

vector temps; // temperatures

for (double temp; cin>>temp; ) // read into temp

temps.push_back(temp); // put temp into vector

// . . . do something . . .

}

double temp;

while (cin>>temp) // read

temps.push_back(temp); // put into vector

// temp might be used here

// compute mean and median temperatures

int main()

{

vector temps; // temperatures

for (double temp; cin>>temp; ) // read into temp

temps.push_back(temp); // put temp into vector

// compute mean temperature:

double sum = 0;

for (int x : temps) sum += x;

cout

// compute median temperature:

sort(temps); // sort temperatures

cout

}

// compute average temperature:

double sum = 0;

for (int x : temps) sum += x;

cout

// compute median temperature:

sort(temps); // sort temperatures

cout If we define the median of a sequence as "a number so that exactly as t in the sequence as come after it," fix the at it always prints out a median. Hint: A median need not be an element of the sequen ce

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago