A SIMPLE PROGRAM TO CONVERT THE TEMPERATURE USING C PROGRAMMING LANGUAGE
What Will I Learn?
we will learn how to make a program to convert the temperature.
Example:
- Convert The temperature from Celcius to Reamur, Kelvin, or Fahrenheit
- Convert The temperature From Reamur to Celcius, Fahrenheit, or Kelvin
- Convert The Temperature From Fahrenheit to Celcius, Reamur, or Kelvin
- Convert The Temperature From Kelvin to Celcius, Reamur, or Fahrenheit.
Requirements
Dev C++ 5.11
Difficulty
- Basic
Tutorial Contents
Now, I will Share how to make A simple program to convert the temperature. before I Share Code for the program we must Know what the meaning of temperature. and what the formula to convert The Temperature
The theory Of temperature: Temperature is a physical quantity which declared degrees of heat cold an object and a device used to measure temperature is the thermometer. In the daily life of the community to measure temperature tend to use the sense of touch. But with the development of technology then created one thermometer to measure the temperature with a valid.
There are several scale units of temperature, eg Celsius (C), Reamur (R), Fahrenheit (F), and Kelvin (K). Among the surnames of the scale, the scale of the Celsius scale is the most widely used in various countries around the world, except countries of the United Kingdom speaking, they generally use the Fahrenheit scale.
in the case of the first one is to change or convert temperature from Celsius to Fahrenheit, Reamur, and Kelvin. The formula that is used to convert Celsius to Reamur is R = (4/5) C, next to convert Celsius to Fahrenheit used the formula F = (9/5) C + 32, to convert Celsius to Kelvin then used the formula K = C + 273,
For the second case is the conversion of temperature from Fahrenheit (F) to Celsius (C), Reamur (R), and Kelvin (K), the formula is:
c = 5/9 (F-32)
R = 4/9 (F-32)
K = 5/9 (F-32) + 273
in the case of the third is temperature conversion from Reamur (R) to degrees Celsius (C), Fahrenheit (F), and Kelvin (K), the formula is:
C = (5/4) R
F = (9/4) R + 32
K = C + 273 = (5/4) + 273 R
in the case of the second is the conversion of temperature from Fahrenheit (F) to Celsius (C), Reamur (R), and Kelvin (K), the formula is:
c =5/9 (F-32)
R = 4/9 (F-32)
K = 5/9 (F-32) + 273
For the fourth Case, temperature conversion Kelvin (K) to degrees Celsius (C), Reamur (R), Fahrenheit (F) the formula is:
C = K – 273
R = 4/5 (K-273)
F = 9/5 (K-273) + 32
Description: Celsius (C), Reamur (R), Fahrenheit (F), and Kelvin (K).
Code For The Program
int main()
{
float temperature, Result;
int kind;
char back;
printf("==========================================\n");
printf("A Simple Program To Convert The Temperature\n");
printf("==========================================\n");
Repeat :
printf("Select the temperature unit you want to convert : \n");
printf("1. Celcius\n");
printf("2. Fahrenheit\n");
printf("3. Reamur\n");
printf("4. Kelvin\n");
printf("Please Select : ");
scanf("%d", &kind);
switch(kind)
{
case 1:
printf("Insert the large temperature : ");
scanf("%f", &temperature);
Result=(temperature*1.8)+32;
printf("Farenheit : %.2f Fahrenheit\n",Result);
Result=temperature*0.8;
printf("Reamur : %.2f Reamur\n",Result);
Result=temperature+273.15;
printf("Kelvin : %.2f Kelvin\n",Result);
break;
case 2:
printf("Insert the large temperature : ");
scanf("%f", &temperature);
Result=(temperature-32)/1.8;
printf("Celcius : %.2f Celcius\n",Result);
Result=(temperature-32)/2.25;
printf("Reamur : %.2f Reamur\n",Result);
Result=((temperature-32)/1.8)+273.15;
printf("Kelvin : %.2f Kelvin\n",Result);
break;
case 3:
printf("Insert the large temperature : ");
scanf("%f", &temperature);
Result=temperature/0.8;
printf("Celcius : %.2f Celcius\n",Result);
Result=(temperature*2.25)+32;
printf("Farenheit : %.2f Fahrenheit\n",Result);
Result=(temperature/0.8)+273.15;
printf("Kelvin : %.2f Kelvin\n",Result);
break;
case 4:
printf("Insert the large temperature : ");
scanf("%f", &temperature);
Result=temperature-273.15;
printf("Celcius : %.2f Celcius\n",Result);
Result=((temperature-273.15)*1.8)+32;
printf("Farenheit : %.2f Fahrenheit\n",Result);
Result=(temperature-273.15)*0.8;
printf("Reamur : %.2f Reamur\n",Result);
break;
default:
printf("\n");
goto Repeat;
}
}
Result Work:
When the program is run it will pop up the first time is the title of the next program is followed with some options to convert temperatures. The first option is for Celsius, the second is Fahrenheit, the third is Reamur, and the fourth is the Kelvin. The next user will be prompted to enter the selection type of the temperature that will be converted.
For example:
On the main menu let users choose the type of the first temperature Celsius, then the user will be prompted to enter the temperature value. After that, the program will insert the values into the formula that's been determined to turn Celsius into Fahrenheit, Reaumur, and Kelvin. For example, enter values of Celsius is 32 so if in conveconvertahrenheit is F = (9/5) + 32 32 so that the result is 89.60. Furthermore, if the Celsius in convert to Reamur then the formula is R = (4/5) + 32 the result is 25.60. Further, convert from Celsius to Kelvin, the formula used is K = 273 + 32 so that the result is 305.15.
~~~Thank You ~~~
~~~Created by: Baixiian~~~
Posted on Utopian.io - Rewarding Open Source Contributors
Keep going ! :)
I am currently studying computer sience and I really like what you do.
Thanks...
haha, i did this in ms-dos back in the day; converting Fahrenheit to kelvin for an analytical instrument.
only can laughing.... :)
Awesome tutorial!
Your contribution cannot be approved because it does not follow the Utopian Rules.
You can contact us on Discord.
[utopian-moderator]