Fahrenheit-Celsius converter

 

Basically, the new task was to create a program that, in words of our professor , “will prompt the user for a temperature in Fahrenheit and then convert it to Celsius…” We were also asked to make the program able of telling if water would boil at the specific temperature given by the user.

For that last part, I decided to use an If-Else cycle. Here you can have a look into my code:

#include <iostream>

using namespace std;
float f, c;

int main(){
cout << “Provide the temperature in Fahrenheit: ” << endl;
cin >> f;

c = 5 * ((f – 32)/9);

cout << “Your temperature in degrees celsius is: ” << c << endl;

if (c < 100)
cout << “Water does not boil at this temperature”;
else if (c <= 0)
cout << “Water freezes at this temperature”;
else
cout << “Water boils at this temperature”;

}

Whenever I don´t remember something, I check a really useful webpage. Here you can take a look at it. Have fun! Hopefully it helps someone.

CC BY-SA 4.0 Fahrenheit-Celsius converter by netosanchezb is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.