Write a C program to convert temperature from Fahrenheit to Celsius and vice- versa.

First open CodeBlocks and create a file.Then save the file named test.cpp.Then write the following simple C code.Finally Run the Code.

Code:


#include<stdio.h>
#include<conio.h>
int main()
{
float f,c;
char a;
printf("TO convert from FARENHEIT to CELCIUS Press 'C'\n");
printf("TO convert from CELCIUS TO FARENHEIT Press 'F'\n");
a=getch();
if(a=='C'|| a=='c')
{
printf("Enter the value of Farenheit\n");
scanf("%f",&f);
c=.56*(f-32);
printf(" Celcius  value is : %.2f",c);
}
else if(a=='F'||a=='f')
{
printf("Enter the value in celcius\n");
scanf("%f",&c);
f=1.8*c+32;
printf("Farenheit  value is : %.2f",f);
}
else
{
printf("Please press correct letter!");
}
return 0;
}

Output: