FAQ: Variables - Challenge: Temperature (Part 1)


This community-built FAQ covers the “Challenge: Temperature (Part 1)” exercise from the lesson “Variables”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn C++

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 (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 (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

1 Like

Every other step has been cleared, but when compiling I suddenly get a slew of errors saying every time I wrote tempf or tempc there were two or more data (the error trails off the screen) in declaration of ‘tempc’ or ‘tempf’. But the code was entered correctly every other step, so what is the issue now?


This is dogshit. Why am I not able to use endl, using namespace std, etc. Really aggravating me that you can’t use unique solutions. Whoever made it so there can’t be more than one way to solve it is ■■■■■■■■. I’m sorry for my anger, but over time it gets really irritating.


I’m sorry you dislike the syntax preferences of Codecademy, but what they do is they stick with one form of syntax, and that syntax can be annoying for most of us, even though it’s actually valid.

The code you make outside of Codecademy is fine, no matter what way you use the syntax.

#include <iostream>
using namespace std;

int main() {
    cout << "Hello World!" << endl;
    return 0;


But in Codecademy, you’re forced to use their syntax, and not what you choose.

#include <iostream>

int main() {

    std::cout << "Hello World!\n";

    return 0;


If you choose to learn from Codecademy, then you’ll probably have to use their syntax to proceed. It may seem terrible to you, but it’s fine.

Because when you complete their courses, you can choose whatever valid form of syntax you choose.


Step 4 needs to be a little more explicit in its instruction. How should we compile,

$ g++ temperature.cpp
$ ./a.out


$ g++ temperature.cpp -o temperature
$ ./temperature

It would appear the first one is the way to go. Has anyone succeeded using the other?


hey @leonhardeuler9754768 this is sonny, the curriculum developer for this course. i definitely want to allow different solutions. this is something im definitely going to tackle.

it’s going to take me a few days to add two additional tests for each one of the checkpoints. will do it asap.


hey @kapow512, can you copy and paste your code in here so i can take a look? thank u~

1 Like

@mtf hey roy, looking into it!


u are right! im adding the test for the second one right now and also adding a hint.

UPDATE: fixed.


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:


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.


Should that be,

#include <iostream>



I am not sure why it isn’t showing in the window, but I do have that line "#include <iostream> "



int main() {

double tempf = 83.0;
double tempc;
tempc = (tempf - 32) / 1.8;

std::cout<<“The temp is " <<tempc<<” degrees Celsius.\n";



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!


I am getting an error when I try to compile. Here’s my code:


int main() {

double tempf;
double tempc;

// Ask the user

std::cout << "Enter the temperature in Fahrenheit: ";
std::cin >> tempf;

tempc = (tempf - 32) / 1.8;


I can’t cut and paste the error message, but it’s pretty long winded and trails off the screen.



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.


Hi there, im no expert, but I had to put the code in parenthesis like this:

(tempc = (tempf - 32) / 1.8 );

That seemed to resolve the long weird error message for me. good luck!


std::cout << (tempc = (tempf-32)/ 1.8);

if you do (tempc = (tempf-32)/ 1.8);

without the std::cout << should work fine.