65 lines
1.5 KiB
C
65 lines
1.5 KiB
C
/*
|
|
* =====================================================================================
|
|
*
|
|
* Filename: CelsiusToFahr.c
|
|
*
|
|
* Description:
|
|
*
|
|
* Version: 1.0
|
|
* Created: 10/06/26 10:26:44 PM IST
|
|
* Revision: none
|
|
* Compiler: gcc
|
|
*
|
|
* Author: YOUR NAME (),
|
|
* Organization:
|
|
*
|
|
* =====================================================================================
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
/*
|
|
* NEW IMPORTANT LEARNING:
|
|
*
|
|
* '\t' character don't print same number
|
|
* of white-space.
|
|
*/
|
|
|
|
/* print Celsius-Fahrenheit table
|
|
* for celsius = 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 */
|
|
|
|
celsius = lower;
|
|
|
|
const char celsius_string [ ] = "Celsius";
|
|
const char fahr_string [ ] = "Fahrenheit";
|
|
|
|
printf ( "=============================" );
|
|
putchar ( '\n' );
|
|
printf ( " Temperature table " );
|
|
putchar ( '\n' );
|
|
printf ( "=============================" );
|
|
putchar ( '\n' );
|
|
printf ( "%s\t%s", celsius_string, fahr_string );
|
|
putchar ( '\n' );
|
|
printf ( "=============================" );
|
|
putchar ( '\n' );
|
|
|
|
while ( celsius <= upper ) {
|
|
fahr = ( 9.0 / 5.0 ) * celsius + 32.0;
|
|
printf ( "%7.0f\t%10.1f\n", celsius, fahr );
|
|
celsius = celsius + step;
|
|
}
|
|
|
|
return 0;
|
|
}
|