Chapter 01 in progress

This commit is contained in:
2026-06-10 23:24:38 +05:30
commit 00a3d41e39
5 changed files with 3068 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
/*
* =====================================================================================
*
* 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;
}