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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started