Learn

Now that we’ve learned about the basics of variables and cin, let’s write a program!

The mad scientist Kelvin has mastered predicting the weather in his mountain-side meteorology lab.

Recently, Kelvin began publishing his weather forecasts on his website, however, there’s a problem: All of his forecasts describe the temperature in Fahrenheit degrees.

Let’s convert a temperature from Fahrenheit (F) to Celsius (C).

The formula is the following:

C=(F32)/1.8C = (F - 32) / 1.8

Instructions

1.

First, google the current temperature of New York in Fahrenheit.

Declare a double variable named tempf and initialize it with the temperature.

Declare another double variable named tempc.

2.

Calculate the temperature to Celsius.

Store it in tempc.

3.

Display the result.

Output exactly this:

The temp is [tempc] degrees Celsius.

Don’t forget to add a \n.

4.

Compile the program using the terminal.

5.

Now execute the output file using the terminal.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?