FAQs on the exercise Challenge: Temperature (Part 1)
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
I am currently working on step 3 (Display the result). The code looks right to me, but I can’t get past this step. Everytime I try to run the code, I get an error that says: “Did output the exact same phrase?”
Here is the code that I have so far:
#include
int main() {
double tempf = 37.0;
double tempc;
tempc = (tempf - 32) / 1.8;
std::cout << “The temp is " << tempc << " degrees Celcius.\n”;
}
I even looked at the hints to figure this out, but I can’t see what’s wrong.
Its Celsius not Celcius and in line " degrees…" first place is blank-with space.
First line include is not appear all because of brackets…(at this forum answers)
So I got my code looking just like your example (even correction the spelling of Celsius), but it did not work initially. To get it to work, I had to completely erase everything and retype it, and then it actually worked! Thanks for your help!
Thanks for responding and looking to adapt the tutorial! I come from a less formal scripting background so forgive me if my terminology isn’t exact. This was the only tutorial so far that was a bit confusing. I’d clarify “double” as a the type of variable and the “tempf” and “tempc” as the names of of the variable in the instruction text. And remind the student that there doesn’t need to be a “= value” after the name (I forgot and that’s what confused me).
I ended up doing something like:
double tempf =41
double tempc = C
C = (tempf-32)/1.8;
Once I saw the solution it made sense, but since it was the first time I’d seen “double” and forgot about the not needing “= value” in this context, I fumbled a bit.
So far the tutorials have been great for this new coder! Thanks for all the hard work!
Hi there, thanks for putting this course up on Codecademy for free!
while doing this lesson, im noticing that my results shows up twice in my final message on the console. Here’s my code:
double tempf = 0;
double tempc = 0;
std::cout << “Enter the temperature in Fahrenheit \n”;
std::cin >> tempf;
std::cout << (tempc = (tempf-32)/ 1.8);
std::cout << “The temp is " << tempc << " degrees Celsius.\n”;
return 0;
After I have the user enter a temperature (54°) for Fahrenheit, i’ll get a message along the lines of:
“12.2222The Temp is 12.2222 degrees Celsius.”
Please, can someone explain why my result of the calculation is turning up twice? thanks.
I keep getting an error saying a ‘;’ is expected before ‘std’. I have a ‘;’ at the end of 1.8 and before ‘std’. What am i doing wrong? Also, i would’ve cut and pasted the error message but it doesn’t seem to be allowed?
Are you getting an error when you compile the code, or when you click “Run”? The lesson wants the message to be exactly as directed. From your post it appears you are missing a space after “is” and also before “degrees”. There should be a period following “Celsius” as well. When you paste code into a post, please format it as code by clicking on the </> icon first, and then pasting your code in the space specified. That will preserve formatting, and allow special characters from your code to show up. For example:
#include <iostream>
Hope this helps! If not, post your code again. Good luck!