--Originally published at The Clueless Programmer
Here I go again, clueless programmer on the go hitting you up with another awesome blog post. That´s what I would say if I indeed made awesome blog posts. Anyway, let´s get right to it.
This time the assignment was more difficult than the last one, but still, I managed. This was the first program that asked us to use an “if” conditional (a conditional that only applies if you trigger the if).
#include <iostream>
using namespace std;
int main()
{
int n1, n2;
cout<<“Write the temperature in Fahrenheit degrees: “;
cin>>n1;
n2=(5*(n1-32))/9;
cout<<n1<<” Fahrenheit degrees convert to “<<n2<<” Celsius degrees”<<endl;
if (n2>=100)
{
cout<<“Water boils at this temperature”<<endl;
}
else
{
cout<<“Water doesn´t boil at this temperature”<<endl;
}
}
There you have the program!
Basically what I do is ask you for a temperature in Fahrenheit degrees, which I save on a variable, then on another variable I save that Fahrenheit temperature converted into a Celsius one. Then I put the ifs down, if the conversion is bigger or the same as a hundred, water boils at that temperature, if it is lower, it doesn´t.
Simple stuff right? (I can bet karma will hit me up with a really difficult assignment really soon, but I´ll enjoy my time until then). So yeah hope you learned something, as always thanks for reading me and hang in there, program on.