# Fahrenheit – Celsius C Program

#### Program 1

Fahrenheit - Celsius C Program Using 'While' Loop
```/*---------- Fahrenheit - Celsius C Program Using While Loop--------*/
#include
main(){
int fahr, celsius;
int lower, upper, step;
lower = 0;   // lower limit of temperature table
upper = 300; // upper limit
step  = 20;  // step size
clrscr();
fahr  = lower;
printf("\n");
printf("\tFahrenheit\tCelsius\n");
while (fahr <= upper)
{
celsius = 5 * (fahr - 32 ) / 9;
printf("\t%d\t\t%d\n", fahr, celsius);
fahr = fahr + step;
}

getch();
return;
}```

#### Program 2

Fahrenheit - Celsius C Program Using 'For' Loop
```/*---------- Fahrenheit - Celsius C Program Using For Loop--------*/
#include
main(){
int fahr;
printf("\tFahrenheit\tCelsius\n");
for( fahr=0; fahr<= 300; fahr=fahr+20)
{
printf("%3d %6.1f\n", fahr, (5.0/9.0) * (fahr-32));
}
getch();
return;
}```

#### Program 3

Fahrenheit - Celsius C Program Using for And symbolic define
```/*---------- Fahrenheit - Celsius C Program Using 'For' And symbolic 'define'--------*/
#include

#define LOWER 0
#define UPPER 300
#define STEP 20
main(){
int fahr;
printf("\tFahrenheit\tCelsius\n");
for( fahr=LOWER; fahr<= UPPER; fahr=fahr+STEP)
{
printf("%3d %6.1f\n", fahr, (5.0/9.0) * (fahr-32));
}
getch();
return;
}```

#### Output

[caption id="attachment_1527" align="aligncenter" width="640"] Fahrenheit - Celsius C Program[/caption]