Chapter 01 in progress
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* =====================================================================================
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* =====================================================================================
|
||||
*
|
||||
* Filename: file_copying.c
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Version: 1.0
|
||||
* Created: 10/06/26 11:03:43 PM IST
|
||||
* Revision: none
|
||||
* Compiler: gcc
|
||||
*
|
||||
* Author: YOUR NAME (),
|
||||
* Organization:
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* NEW IMPORTANT LEARNING
|
||||
*
|
||||
* 1.
|
||||
* EOF value is bigger than
|
||||
* what can be stored in a variable
|
||||
* with char data-type.
|
||||
*
|
||||
* 2.
|
||||
* for example,
|
||||
* c = getchar ( ) is an expression
|
||||
* which evaluates and return a value
|
||||
* of c variable after the assignment.
|
||||
* This is, hence, used in much larger
|
||||
* expression.
|
||||
*/
|
||||
|
||||
/* copy input to output */
|
||||
|
||||
int
|
||||
main ( ) {
|
||||
|
||||
/* int c; */
|
||||
|
||||
/* while ( ( c = getchar ( ) ) != EOF ) */
|
||||
/* putchar ( c ); */
|
||||
|
||||
|
||||
int a = EOF;
|
||||
|
||||
printf ( "%d\n", a );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* =====================================================================================
|
||||
*
|
||||
* Filename: hello.c
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Version: 1.0
|
||||
* Created: 14/05/26 03:03:56 PM IST
|
||||
* Revision: none
|
||||
* Compiler: gcc
|
||||
*
|
||||
* Author: YOUR NAME (),
|
||||
* Organization:
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main ( ) {
|
||||
|
||||
printf ( "hello, " );
|
||||
printf ( "world" );
|
||||
printf ( "\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
+2863
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user