C program to covert Temperature (Celsius to Fahrenheit and Fahrenhiet to celsius)

#include<stdio.h>
main()
{


float a,f,c,t,T;
   printf("Enter \n1 to convert Fahrenheit to celcius \n2 to convert celsius to fahrenheit \n");
   scanf("%f",&a);
if(a==1)
{
printf("Enter temp in fahrenheit \n ");
scanf("%f",&t);
c=((5*t-160)/9.0);
printf("Temp in celcius is %f \n ",c);
}
else if (a==2)
{
printf("Enter temp in celcius\n");
scanf("%f",&T);
f=(9.0/5*T+32);
printf("Temp in fahrenheit is %f\n",f);
}
}





- Here firstly user is asked to choose any option to convert either Celsius to Fahrenheit . Then after choosing the option , user is asked to input temperature and its equivalent temperature is displayed.


Output Will be as:



 

Post a Comment

0 Comments