Question: //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

//program 4.6.3 below
int main()
{
vector
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
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
Get step-by-step solutions from verified subject matter experts
