The following is an attempt to display a table of Celsius temperatures and their Fahrenheit equivalents in the range 0 to 20. int celsius;
for ( celsius = 0; celsius <= 20; celsius =+ 1 );
{
double f = 9 / 5 * celsius + 32;
cout << celsius << " C == "
<< f << " Fahrenhiet "
<< endl;
}

Although this code compiles without complaint, it has more than one mistake. Pick the answer that correctly identifies a mistake with the use of the C++ iteration statement.

A. The double variable f must be declared prior to the for loop.
B.
The correct for loop header for this iteration is,
for ( celsius = 0; celsius < 20; celsius =+ 1 )
C.
Remove the semicolon from the line with the for loop header.
D.
The statement that computes the equivalent temperature in Fahrenheit is wrong. It should be the following,

double f = 9.0 / 5.0 * celsius + 32;

Solved
Show answers

Ask an AI advisor a question