59 lines
1.4 KiB
C
59 lines
1.4 KiB
C
/*
|
|
* =====================================================================================
|
|
*
|
|
* Filename: temp_conversion.c
|
|
*
|
|
* Description:
|
|
*
|
|
* Version: 1.0
|
|
* Created: 10/06/26 10:03:10 PM IST
|
|
* Revision: none
|
|
* Compiler: gcc
|
|
*
|
|
* Author: YOUR NAME (),
|
|
* Organization:
|
|
*
|
|
* =====================================================================================
|
|
*/
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
/* print Fahrenheit-Celsius table
|
|
* for fahr = 0, 20, ...., 300 */
|
|
|
|
int
|
|
main ( ) {
|
|
|
|
float fahr, celsius;
|
|
int lower, upper, step;
|
|
|
|
lower = 0; /* lower limit of temperature table */
|
|
upper = 300; /* upper limit */
|
|
step = 20; /* step size */
|
|
|
|
fahr = lower;
|
|
|
|
const char fahr_string [ ] = "Fahrenheit";
|
|
const char celsius_string [ ] = "Celsius";
|
|
|
|
printf ( "=============================" );
|
|
putchar ( '\n' );
|
|
printf ( " Temperature table " );
|
|
putchar ( '\n' );
|
|
printf ( "=============================" );
|
|
putchar ( '\n' );
|
|
printf ( "%s\t%s", fahr_string, celsius_string );
|
|
putchar ( '\n' );
|
|
printf ( "=============================" );
|
|
putchar ( '\n' );
|
|
|
|
while ( fahr <= upper ) {
|
|
celsius = 5.0 * ( fahr - 32.0 ) / 9.0;
|
|
printf ( "%10.0f\t%6.1f\n", fahr, celsius );
|
|
fahr = fahr + step;
|
|
}
|
|
|
|
return 0;
|
|
}
|