![haleeleslie](/avatars/31086.jpg)
haleeleslie
07.05.2021 •
Computers and Technology
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
More tips
- C Computers and Internet How to Top Up Your Skype Account Without Losing Money?...
- H Health and Medicine How does childbirth happen: everything future mothers need to know...
- H Health and Medicine What Are the Best Vitamins? A Scientific View on Vitamin Supplements...
- A Auto and Moto How to Deregister a Car in Moscow?...
- A Auto and Moto What Is the Cost of Customs Clearance for a Car in Russia?...
- A Auto and Moto How to choose the right drive for your BMW...
- H Health and Medicine 10 Tips for Avoiding Vitamin Deficiency...
- L Leisure and Entertainment Mysteries of the Name Vyacheslav Dobrynin...
- H Health and Medicine What makes Graves’ disease dangerous?...
- F Food and Cooking When is Easter in 2011?...
Answers on questions: Computers and Technology
- C Computers and Technology What possible effects could cyber attack have on johannesburg stock exchange...
- C Computers and Technology What is the preferences of occupation in ones life?...
- C Computers and Technology The primary objective of database design is what? a) to be able to add data quickly b) to create the most efficient database possible c) to create the fastest queries d) to create...
- H History What industry had a significant economic impact on the New England colonies? Farming Fishing Hunting Mining...
- M Mathematics 3 7 A girl spends of her pocket money on snacks and of what 7 8 is left on clothes. If she has GH¢ 261 left, how much is her pocket money?...
- M Mathematics Im giving Brainliest to the correct answer...
- C Chemistry f Assignment: 04.03 Cell Structure and Functions Details Submit the assignment following the instructions in the lesson Points Possible 30 Course Contribution Submissions Allowed 0...
- E English CAUSE BABY NOW WE GOT BAD BLOOD AYEE WHATS THE Alliteration!?!?!/1 - Alliteration Alliteration happens when words that start with the same sound (not just the same letter) are used...
- M Mathematics A restaurant needs a block of ice that is exactly 480 cubic inches in volume. The height of the ice block must be 10 inches....
- M Mathematics A rectangular plastic tarp is 4 times as long as it is wide. Its width is 8 meters. What is the perimeter of the plastic tarp...
Ответ:
The corrected code is as follows:
using System;
using static System.Console;
class DebugTwo2{
static void Main(string[] args){
string name;string firstString, secondString;
int first, second, product;
Write("Enter your name >> ");
name = ReadLine();
Write("Hello, {0}! Enter an integer >> ", name);
firstString = ReadLine();
first = Convert.ToInt32(firstString);
Write("Enter another integer >> ");
secondString = ReadLine();
second = Convert.ToInt32(secondString);
product = first * second;
Write("Thank you, {0}. The product of {1} and {2} is {3}", name,first, second, product);
}
}
Explanation:
string name;string firstString, secondString; Replace secondSting with secondString,
int first, second, product;
Write("Enter your name >> "); --- Here, the quotes must be closed with corresponding quotes "
name = ReadLine(); The syntax of readLine is incorrect without the () brackets
Write("Hello, {0}! Enter an integer >> ", name);
firstString = ReadLine();
first = Convert.ToInt32(firstString); There is a dot between Convert and ToInt32
Write("Enter another integer >> ");
secondString = ReadLine(); --- Readline() should be written as ReadLine()
second = Convert.ToInt32(secondString);
product = first * second;
Write("Thank you, {0}. The product of {1} and {2} is {3}", name,first, second, product); --- The formats in {} should start from 0 because 0 has already been initialized for variable name
}
}