From 0d53df1c65d31551d2be872b39ec22d8c7849f31 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Mon, 31 Aug 2020 21:59:22 -0400 Subject: [PATCH] Updated readme. Going through first chapter --- README.md | 10 +++++++++- ch_01/hello_world/hello_world.c | 14 ++++++++++++++ ch_01/new_line_character/new_line.c | 16 ++++++++++++++++ ch_01/temperature_conversion/conversion.c | 23 +++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 ch_01/hello_world/hello_world.c create mode 100644 ch_01/new_line_character/new_line.c create mode 100644 ch_01/temperature_conversion/conversion.c diff --git a/README.md b/README.md index 73e85c7..b0f6ff5 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ # Info -A collection of examples, exercises, and experience while learning the C programming language. The source material used to learn C is from *The C Programming Language 2nd Edition by Dennis Ritchie and Brian Kerningham*. The reason I chose this book is due to numerous amounts of programmers acknowledging this as a well put book explaining the language. The book is concise and achieves the objectives of exhibiting how the language can be used and inspiring to further advancement. Though C is a small language this book serves as a good read to get acquainted with C. There aren't vast examples or tirades delving into painstakingly detailed concepts. It's a good introductory book. I get a good grasp of the language. Even more, I get to learn C as C. Instead of falling into the trap when learning a new language without getting used to it. I know C++ but C shouldn't be viewed as C++ without all of the extra stuff. After all, C++ was originally meant to be a subset of C but never did. +A collection of examples, exercises, and experiments while learning the C programming language + +## Resources and tools used +* Book - **The C Programming Language 2nd Edition** *by Dennis Ritchie and Brian Kerningham* +* Compiler - GCC >= 8 +* Linux OS + + +The source material used to learn C is from *The C Programming Language 2nd Edition by Dennis Ritchie and Brian Kerningham*. The reason I chose this book is due to numerous programmers acknowledging this as a well put together book explaining the language. The book is concise and achieves the objective of exhibiting how the language can be used and inspires further advancement. Though C is a small language this book serves as a good read to get acquainted. There aren't vast examples or tirades delving into painstakingly detailed concepts. It's a good introductory book. Even more, I get to learn C as C. Instead of falling into the trap when learning a new language without getting used to it. I know C++ but C shouldn't be viewed as C++ without all of the extra stuff. After all, C++ was originally meant to be a subset of C but never did. diff --git a/ch_01/hello_world/hello_world.c b/ch_01/hello_world/hello_world.c new file mode 100644 index 0000000..da8d757 --- /dev/null +++ b/ch_01/hello_world/hello_world.c @@ -0,0 +1,14 @@ +/* + * Simple hello world application + * + * Author: Kun Deng + */ + +#include + +int main() +{ + printf("hello, world\n"); + + return 0; +} diff --git a/ch_01/new_line_character/new_line.c b/ch_01/new_line_character/new_line.c new file mode 100644 index 0000000..297b265 --- /dev/null +++ b/ch_01/new_line_character/new_line.c @@ -0,0 +1,16 @@ +/* + * Another way to print a new line + * + * Author: Kun Deng + */ + +#include + +int main() +{ + char new_line = 0x0A; + + printf("hello, world%c", new_line); + + return 0; +} diff --git a/ch_01/temperature_conversion/conversion.c b/ch_01/temperature_conversion/conversion.c new file mode 100644 index 0000000..86a7f76 --- /dev/null +++ b/ch_01/temperature_conversion/conversion.c @@ -0,0 +1,23 @@ +/* + * Converts temperatures from fehrenheit to celsius starting from 0 to 200. Incrementing by 10 + * + * Author: Kun Deng + */ + +#include + +#define UPPER 200 +#define LOWER 0 +#define STEP 10 + +int main(int argc, char **argv) +{ + printf("%13s %13s\n", "fahrenheit", "celsius"); + + for (double fahrenheit = LOWER; fahrenheit <= UPPER; fahrenheit = fahrenheit + STEP) + { + printf("%13.2f %13.2f\n", fahrenheit, ((fahrenheit - 32) * 5.0 / 9.0)); + } + + return 0; +}