Use the following functions:
double celsius2fahrenheit (double celsius) {
return celsius * 9 / 5 + 32;
}
double fahrenheit2celsius (double fahrenheit) {
return (fahrenheit - 32) * 5 / 9;
}
#include <iostream>
using namespace std;
int main()
{
double x;
cout << "Enter temperature in celcius: ";
cin >> x;
cout << x * 9 / 5 + 32 << endl;
char wait;
cin >> wait;
return 0;
}
The following functions will provide all the conversions you need.
double celsius_to_fahrenheit (double c) {
return c * 9 / 5 + 32;
}
double fahrenheit_to_celsius (double f) {
return (f - 32) / 9 * 5;
}
double celsius_to_kelvin (double c) {
return c + 273.15;
}
double kelvin_to_celsius (double k) {
return k - 273.15;
}
double fahrenheit_to_kelvin (double f) {
return celsius_to_kelvin (fahrenheit_to_celsius (f));
}
double kelvin_to_fahrenheit (double k) {
return celsius_to_fahrenheit (kelvin_to_celsius (k));
}
The conversion from Celsius to Fahrenheit in assembly language is not different from the same conversion in any other programming language; all implement the same formula F = 32 + C * 9/5, where F is the temperature in Fahrenheit and C is the same temperature in Celsius.
Details of the implementation in a specific assembly language are of course subject to the definition of that particular assembly language.
To convert temperature from Fahrenheit to Celsius we use a simple function that accepts a temperature in Fahrenheit and returns the equivalent temperature in Celsius. To achieve this we need to know the formula to convert from Fahrenheit to Celsius. This can easily be calculated by comparing 0 degrees Celsius and 100 degrees Celsius to the equivalent temperatures in Fahrenheit:
0 degrees Celsius = 32 degrees Fahrenheit
100 degrees Celsius = 212 degrees Fahrenheit
From the first temperature we can see that the two scales are offset by exactly 32 degrees, so we must subtract 32 degrees from the Fahrenheit temperature in order to align both scales with zero.
0 degrees Celsius = 0 + 32 degrees Fahrenheit 100 degrees Celsius = 180 + 32 degrees Fahrenheit
Having aligned the two scales, we can now see that a difference of 100 degrees Celsius is exactly equivalent to a difference of 180 degrees Fahrenheit. Combining the offset (32) with the ratio (100/180), we obtain the following conversion formulas, where C is the temperature in degrees Celsius and F is the temperature in degrees Fahrenheit:
C = (F-32)*(100/180) = (F-32)*(5/9) = (F-32)*0.55555...
or
C = (F-32) / (180/100) = (F-32)/(9/5) = (F-32)/1.8
Note that we must use parenthesis to ensure the correct order of evaluation (division normally has a higher precedence than subtraction).
These formulas are exactly equivalent, so it is merely a matter of taste which you prefer in code:
double fahrenheit_to_celsius (double f) { return (f-32)*5/9; }
or
double fahrenheit_to_celsius (double f) { return (f-32)/1.8; }
Note that we cannot express 0.55555... explicitly in code (it would be non-portable) so we must use 5/9 to gain maximum precision across all implementations. However, 5/9 is a constant expression and therefore a compile-time operation, so there is no runtime cost.
Usage:
double c1 = fahrenheit_to_celsius (32.0); // c1 = 0.0 (freezing point of water)
double c2 = fahrenheit_to_celsius (212.0); // c2 = 100.0 (boiling point of water)
double c3 = fahrenheit_to_celsius (-40.0); // c3 = -40.0 (parity)
double c4 = fahrenheit_to_celsius (-459.67); // c4 = -273.150 (absolute zero: 0 degrees Kelvin)
Now that we know how the formula and function for Fahrenheit to Celsius conversion was constructed, the complementary function should be self-explanatory:
double celsius_to_fahrenheit (double c) { return c*9/5+32; }
or
double celsius_to_fahrenheit (double c) { return c*1.8+32; }
Temperature in Fahrenheit is equal to (9/5 x Temperature in Celsius) + 32
Here's a simple function that will convert Fahrenheit to Celsius for you: function toCelsius(fahrenheit:Number):Number{ var celsius:Number = (fahrenheit - 32) * (5/9); return celsius; } Use: // Converts 60 degrees Fahrenheit to Celsius var newTemperature:Number = toCelsius(60); trace(newTemperature);
0
What does 70 degrees Celsius convert to degrees Fahrenheit? Scroll down to related links and look at "Conversion of temperatures and formulas".
convertFtoC = function(F) {return (5/9)*(F-32) }convertCtoF = function(C) {return (9/5)*C + 32; }
CLS INPUT "Enter degrees in Celsius:";c INPUT "Enter degrees in Fahrenheit:";f a=(c*1.8)+32 b=5/9(f-32) PRINT c;"degree Celsius=" a;"degree Fahrenheit" PRINT f;"degree Fahrenheit=" b;"degree Celsius" end
Formula: Fahrenheit = (Celsius x 1.8) + 32
That's wrong. That's not how you convert temperatures between Celsius and Fahrenheit.
To convert Celsius temperatures into Fahrenheit:Begin by multiplying the Celsius temperature by 9.Divide the answer by 5.Now add 32.122 Degrees Fahrenheit.
To convert temperatures in degrees Celsius to Fahrenheit, multiply by 1.8 (or 9/5) and add 32.
76 degree Fahrenheit is 24.44 Celsius. You do the Math: To convert Fahrenheit temperatures into Celsius: Begin by subtracting 32 from the Fahrenheit number. Divide the answer by 9. Then multiply that answer by 5.
I suggest you convert each of the Fahrenheit temperatures to Celsius (or the other way round, each of the Celsius temperatures to Fahrenheit), and then compare.
How to convert Fahrenheit temperatures to CelsiusSubtract 32o to adjust for the offset in the Fahrenheit scale.Multiply the result by 5/9.Example: convert 98.6o Fahrenheit to Celsius.98.6 - 32 = 66.666.6 * 5/9 = 333/9 = 37o C.
To convert from celsius to fahrenheit use the following formula : F = (C * 9/5) + 32
Formula for conversion between Fahrenheit and Celsius is: Fahrenheit=5/9*Celsius+32 Celsius =(Farenheit-32)*9/5
40 degrees fahrenheit is about 4.4 degrees celsius, while 10 celsius is 50 degrees fahrenheit so 40 fahrenheit is the colder temperature. The formulas to convert between celsius and fahrenheit temperatures (where F is the Fahrenheit temperature and C is the Celsius temperature in degrees) are as follows: Celsius to Fahrenheit: F = C × 9/5 + 32 Fahrenheit to Celsius: C = (F − 32) x 5/9
Convert Fahrenheit to Celsius: Celsius = (5/9) * (Fahrenheit - 32)Convert Celsius to Fahrenheit: Fahrenheit = (9/5) * Celsius + 32Convert Celsius to kelvin: Kelvin = Celsius + 273.15Convert kelvin to Celsius: Celsius = kelvin - 273.15
[°F] = [°C] × 9/5 + 32