Write a program to convert temperature from Celsius to Fahrenheit

Convert temperature from selsius to Fahrenheit
#include<stdio.h>
int main() {
float celsius, fahrenheit;
printf("\nEnter temp in Celsius : ");
scanf("%f", &celsius);
fahrenheit = (1.8 * celsius) + 32;
printf("\nTemperature in Fahrenheit : %f ", fahrenheit);
return (0);
}
Output :




Enter temp in Celsius : 32
Temperature in Fahrenheit : 89.59998

Convert Fahrenheit to Celsius

Q. Write a C program to convert Fahrenheit to Celsius temp temperature.

or
Q. Write a C program to accept temperature in Fahrenheit  from user and convert into the Celsius.


Ans.


/*C program to convert Fahrenheit to Celsius*/
/*Formula(Fahrenheit to Celsius):
Celsius = (Fahrenheit - 32) / 1.8
*/
#include<stdio.h>
#include<conio.h>
int main()
{
 float fh,cl;
 printf("Enter temperature value in Fahrenheit: ");
 scanf("%f", &fh);
 cl = (fh - 32) / 1.8;
 printf("Converted Celsius value: %f",cl);
 getch();
 return 0;
}



Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

1 comments: