WSQ 02 Temperature

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

1 comentario

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Salir /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Salir /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s