Learn about Fahrenheit to Celsius C Program using While loop in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Fahrenheit to Celsius C Program using While loop
Program:
#include<stdio.h>
int main()
{
float celsius, fahr ;
int lower, upper, step ;
lower=100, upper=300, step=50 ;
fahr = lower ;
while ( fahr <= upper )
{
celsius = (5.0/9.0) * (fahr - 32) ;
printf("%3.0f \t %6.1f \n", fahr , celsius) ;
fahr += step ; // fahr = fahr + step
}
return 0;
}
Output:
100 37.8 150 65.6 200 93.3 250 121.1 300 148.9
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
Fahrenheit to Celsius C Program
Celsius to Fahrenheit C program using For loop