Question: Debugging a C++ Program The file called Lab4 Debug.cpp is intended to be a C++ program that displays temperatures in Fahrenheit and the equivalent temperature
Debugging a C++ Program The file called Lab4 Debug.cpp is intended to be a C++ program that displays temperatures in Fahrenheit and the equivalent temperature in Celsius. Unfortunately, it doesnt work. There are three errors in it.
1. Copy this file into a new project in Visual Studio.
2. Correct any syntax errors indicated by the error messages.
3. Correct the logic errors using the Hand tracing technique described in section 3.10 so that the program executes and produces correct output as in the example below. Note that it must display temperatures from the low to the high temperatures entered.
#include
int main() { int low, high, fahren; double celsius;
// Ask for the starting temperature cout << "Enter the low temperature in Fahrenheit "; cin >> low;
// Ask for the ending temperature cout << "Enter the high temperature in Fahrenheit "; cin >> high;
// Table Header cout << endl; cout << "Fahrenheit Celsius" << endl; cout << "=====================" << endl;
fahren = 1; while (fahren > high) { // Compute and display the celsius temperature celsius = (fahren - 32.0) * 5.0 / 9.0; cout << "fahrenheit" << " " << celsius << endl; fahren += 1; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
