#include <stdio.h>
int main(){
// 2) Write a program to convert ferhenhite to celcius.
double temp;
char unit1,unit2,Ferhenhite[] = "Ferhenhite",Celcius[] = "Celcius",Kelvin[] = "Kelvin";
printf("Enter the degree temperature you want to convert: ");
scanf("%lf",&temp);
printf("Select the degree of temperature for the entered temperature. (Ferhenhite/Celcius/Kelvin): ");
scanf("%c", unit1);
printf("Select the degree of temperature to be converted for the entered temperature. (Ferhenhite/Celcius/Kelvin): ");
scanf("%c", unit2);
if (unit1==Ferhenhite)
{
if (unit2==Celcius)
{
printf("The entred temperature in celcius is: %lf°",5/9*(temp-32));
}else printf("The entred temperature in kelvin is: %lf°",(temp + 459.67) * 5/9);
}
else if (unit1==Celcius)
{
if (unit2==Ferhenhite)
{
printf("The entred temperature in ferhenhite is: %lf°",(9/5)*temp+32);
}else printf("The entred temperature in kelvin is: %lf°",temp + 273.15);
}
else if (unit1==Kelvin)
{
if (unit2==Celcius)
{
printf("The entred temperature in ferhenhite is: %lf°",temp - 273.15);
}else printf("The entred temperature in celcius is: %lf°",(temp - 273.15) * 9/5 + 32);
}else printf("You have entered wrong unit");
return 0;
}
Error : Comperision between pointer and intergers
C program that can be used to convert temperatures from one unit to another. The program will ask the user for the temperature and the units of the temperature (Ferhenhite, Celsius, or Kelvin). Depending on the units the user enters, the program will calculate and display the temperature in the corresponding unit.