WSQ 02 Temperature

--Originally published at Franco TC1017

Fahrenheit to Celsius Converter. The user gives the Fahrenheit value, the program converts it to Celsius and if it is above 100 degrees Celsius, the program tells the user that water will boil at that temperature, otherwise it will tell the user that water will not boil at room temperature.

This program was easy as there is a formula to convert Fahrenheit to Celsius. I didn’t need any libraries so I only included #include

#include

int main() {

float tempF;
float tempC;

std::cout << “Fahrenheit to Celsius Converter” << ‘\n’;

std::cout << “Enter temperature in Fahrenheit: ” << ‘\n’; std::cin >> tempF;

tempC = 5 * (tempF – 32) / 9;

std::cout << “A temperature of ” << tempF << ” degrees Fahrenheit is ” << tempC << ” degrees Celsius.” << ‘\n’; if (tempC > 100) {
std::cout << “Water would boil at this temperature.” << ‘\n’;
} else {
std::cout << “Water would not boil at this temperature. (25C and 1atm)” << ‘\n’;
}

return 0;
}

temperature-code-blogtemperature-terminal-blog