Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are four major types of errors in C++. Find and specify an error in the following program then explain how you might fix this

There are four major types of errors in C++. Find and specify an error in the following program then explain how you might fix this problem.
#include  #include  using namespace std; int main() { vector temps; // temperatures double temp = 0; double sum = 0; double high_temp = 0; double low_temp = 0; while (cin >> temp) // read and put into temps temps.push_back(temp); for (int i = 0; i < temps.size(); ++i) { if (temps[i] > high_temp) high_temp = temps[i]; // find high if (temps[i] < low_temp) low_temp = temps[i]; // find low sum += temps[i]; // compute sum } cout << "High temperature: " << high_temp << endl; cout << "Low temperature: " << low_temp << endl; cout << "Average temperature: " << sum / temps.size() << endl; } 

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions