Create a program of temperature conversion using basic program
#include <iostream>
using namespace std;
int main()
{
int a = 0;
float cel, far = 0;
cout << "What do you want to convert?\n";
cout << "(0) Celsius to Fahrenheit | Fahrenheit to Celsius (1)\n";
cin >> a;
if (a)
{
cout << "Please enter a Fahrenheit value: ";
cin >> far;
cel = (far - 32) / 1.8f;
cout << far << " degrees Fahrenheit is " << cel << " degrees Celsius";
}
else
{
cout << "Please enter a Celsius value: ";
cin >> cel;
far = cel * 1.8f + 32;
cout << cel << " degrees Celsius is " << far << " degrees Fahrenheit";
}
return 0;
}
Comments
Leave a comment