Celsius into fahrenheit or fahrenheit into Celsius in C language

Write a program to Convert temperature Celsius into fahrenheit or fahrenheit into Celsius


#include <stdio.h>
#include <conio.h>
int main(){
float c,f,temp,temp1;
int selector;
printf("Enter 1 to convert fahrenheit to celcius OR Enter 2 to convert celsius to fahrenheit\n");
scanf("%d",&selector);
if (selector==1)
{
printf("Enter temperature in fahrenheit: ");
scanf("%f",&f);
temp=(f-32.0)*5.0/9.0;
printf("temerature in celsius is %.2f",temp);
}
else if (selector==2)
{
printf("Enter temperature in Celsius: ");
scanf("%f",&c);
temp1 = c*(9.0/5.0)+32;
printf("Temprature in fahrenheit is %.2f ",temp1);
}
else
{
printf("invalid choice");
}
return 0;
}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.