Ask F° and I’ll give you C°

Hello! This is the summery of #WSQ02. The task was to write a program that will ask the user the temperature in Fahrenheit then convert it to Celsius and also if at that temperature the water boils.

This is my code:

temperatura

#include <iostream>
using namespace std;
int main() {
int a, b;
cout <<“Give the temperature in Fahrenheit? “;
cin >> a;

b = ((5*(a-32))/9);
cout << endl << “The temperature in Celcius is ” << b << endl;

if (b >= 100) {
cout << “At this temperature water does boil.”;
}
else {
cout << “At this temperature water DOESN’T boil.”;
}
cout << endl;
return 0;
}

In this program we had to use if.. else it is not that hard to understand, I think is one of the easiest to use. In this example we just need to tell the program that if the number that is given is equal or higher than 100 then the water boils else the water does not boils. That all there is to do, besides the formula to convert F° to C°.

Hope it helped you.

Leave a comment