-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemperature.c
47 lines (46 loc) · 1.49 KB
/
temperature.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<stdio.h>
#include<conio.h>
/* Author:- Tanish Rai
C program for a simple temperature conversion app. */
int main()
{
float Celsius, Kelvin, Fahrenhiet;
int choice;
printf("Choose the unit you want to convert: \n");
printf("1.Kelvin\n");
printf("2.Celsius\n");
printf("3.Fahrenhiet \n");
scanf("%d", &choice);
switch (choice)
{
case 1:
printf("Enter the temperature in kelvin: ");
scanf("%f",&Kelvin);
Celsius = (Kelvin - 273.15);
Fahrenhiet = 1.8 *(Kelvin -273.15) + 32.0;
printf("In Celsius the value is:\t %f °C \n",Celsius);
printf("In Fahrenhiet the value is:\t %f °F",Fahrenhiet);
break;
case 2:
printf("Enter the temperature in Celsius: ");
scanf("%f",&Celsius);
Kelvin = (Celsius + 273.15);
Fahrenhiet = (Celsius * 1.8) + 32.0;
printf("In kelvin the value is : %f K \n",Kelvin);
printf("In Fahrenhiet the value is: %f °F",Fahrenhiet);
break;
case 3:
printf("Enter the temperature in fahrenhite: ");
scanf("%f",&Fahrenhiet);
Kelvin = (Fahrenhiet - 32.0) * 5/9 +273.15;
Celsius = (Fahrenhiet - 32.0) * 5/9;
printf("In Celsius the value is :\t %f °C \n",Celsius);
printf("In Kevlin the value is :\t %f K\n",Kelvin);
break;
default:
printf("Please! enter a valid value \n");
break;
}
printf("\n\n");
return 0;
}