Skip to content

Instantly share code, notes, and snippets.

@enile8
Last active March 7, 2019 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enile8/2311156 to your computer and use it in GitHub Desktop.
Save enile8/2311156 to your computer and use it in GitHub Desktop.
Simple C++ program to convert temperature from either Fahrenheit to Celsius or vise-versa.
/*******************************************************************
* C++ program to convert temperature from either Fahrenheit to *
* Celsius or vise-versa. *
* *
*******************************************************************/
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
int temp, tempCon;
char unit;
cout << "Please enter the temperature and measurement system (c or f): ";
cin >> temp;
cin >> unit;
if ( isupper(unit) )
{
unit = tolower(unit);
}
if (unit == 'f')
{
temp = (temp - 32) / 9.0 * 5.0;
cout << temp << " degrees Celsius\n";
}
else if (unit == 'c')
{
temp = 9.0 / 5.0 * temp + 32;
cout << temp << " degrees Fahrenheit\n";
}
else
{
cout << "Sorry that unit of measure isn't recognized around here.\n";
}
return 0;
}
@UCornelius
Copy link

What is the line by line explanation of the above code please

@sheingg
Copy link

sheingg commented Mar 3, 2017

gumagana po ba nyan ?

@drugscigarettes
Copy link

:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment