In this program user convert the temperature from Fahrenheit to Celsius. User declares required variables for containing the value in it. User declares the value to variables manually to make process of temperature conversion. Then while condition for laying the condition complete. In while condition the method is been used for temperature conversion that are required. Then a printing method to print result on the screen.
Problem Statement:
- Declaring variable.
- Using condition as required.
- Using conversion method.
- Display result on screen
Method for Converting Fahrenheit to Celsius.
“ Celsius = (5.0 / 9.0) * (fahr – 32.0);”
Here is C source code for Converting temperature from Fahrenheit to Celsius. The output of this program shown below.
#include <stdio.h>
int main(void)
{
float fahr, celsius;
int lower, upper, step;
clrscr();
lower = 0;
upper = 300;
step = 20;
printf("F C\n\n");
fahr = lower;
while(fahr <= upper)
{
celsius = (5.0 / 9.0) * (fahr - 32.0);
printf("%3.0f %6.1f\n", fahr, celsius);
fahr = fahr + step;
}
getch();
return 0;
}