Temperature conversion
Temperature conversion
#include < stdio.h >
void main()
{
int from , to;
float value;
printf("Temperature Conversion\n");
printf("Enter no of Unit to covert from : \n 1.celcius\n 2. Farenheit\n 3. Kelvin");
scanf("%d",&from);
printf("Enter no of Unit to covert to : \n 1.celcius\n 2. Farenheit\n 3. Kelvin");
scanf("%d",&to);
printf("Enter The value to convert: ");
scanf("%f",&value);
/*converting given value from specified unit to Kelvin*/
switch(from) {
case 1:
value= value + 273.15; break;
case 2:
value= (value+459.67)*5/9; break;
case 3: break;
default: break;
}
/*converting value from Kelvin to specified unit*/
switch(to) {
case 1:
value= value-273.15; break;
case 2:
value= value*9/5-459.67; break;
case 3: break;
default: break;
}
printf("Converted Value : %f", value);
}
0 comments:
Post a Comment