Fahrenheit to Celsius conversion:
This is a
simple temperature conversion program. In this program ,the given temperature
is in Fahrenheit. This program converts it to Celsius by using a simple
formula.
Program:
“Fahrentocelsius.c”
#include<stdio.h>
#include<conio.h>
void main()
{
/* variable
declaration statement. Fa- Fahrenheit, ce- Celsius */
float fa, ce;
printf(“ Enter
the temperature value in Fahrenheit”);
/* read the
Fahrenheit value */
scanf(“%f”,&fa);
/ * formula
for converting Fahrenheit to Celsius value */
ce=(fa-32)*5/9;
/* The
converted celsius value*/
printf(“The
temperature value in celsius is: %f”,ce);
getch();
}
Try it :
In the same
way, you can try the Celsius to Fahrenheit conversion in your own.
Steps
for converting Celsius to Fahrenheit:
Declare two
variable Celsius,Fahrenheit as float.
Get the
input for Celsius temperature value.
Use the
formula to convert Celsius to Fahrenheit.
Print the
Fahrenheit value.
#include<stdio.h>
#include<conio.h>
void main()
{
float fahren,Celsius;
printf(“
enter the Celsius valus”);
scanf(“%f,&Celsius);
fahren=(Celsius*1.8)+32;
printf(“The
converted value is:%f”,fahren);
getch();
}
No comments:
Post a Comment