From: Steven Baltakatei Sandoval Date: Fri, 12 Aug 2022 22:36:02 +0000 (+0000) Subject: update(src/kr):Finish section 1.5.1 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2023-05.git/commitdiff_plain/29607ac01b10c735406ff0584dd903416623b20a?ds=sidebyside update(src/kr):Finish section 1.5.1 --- diff --git a/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant b/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant new file mode 100755 index 0000000..37dda8f Binary files /dev/null and b/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant differ diff --git a/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant.c b/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant.c new file mode 100644 index 0000000..8e35a55 --- /dev/null +++ b/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant.c @@ -0,0 +1,22 @@ +/* Desc: Prints Fahrenheit-Celsius table; uses symbolic constants + * Usage: name=temp_convert; gcc -o "$name" "$name".c; ./"$name"; + * Ref/Attrib: [0]: The C Programming Language, 2nd Edition, Section 1.4 + */ +#include + +# define LOWER 0 /* Lower limit of table. */ +# define UPPER 300 /* Upper limit of table. */ +# define STEP 20 /* Step size. */ + +/* Print Fahrenheit–Celsius table */ + +int main(){ + int fahr; + for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP) + printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr - 32) ); + return 0; +}; + +/* Author: Steven Baltakatei Sandoval + * License: GPLv3+ + */ diff --git a/src/kr_exercises/ch1/s1.5/get_put_char b/src/kr_exercises/ch1/s1.5/get_put_char new file mode 100755 index 0000000..62b2796 Binary files /dev/null and b/src/kr_exercises/ch1/s1.5/get_put_char differ diff --git a/src/kr_exercises/ch1/s1.5/get_put_char.c b/src/kr_exercises/ch1/s1.5/get_put_char.c new file mode 100644 index 0000000..f2adec6 --- /dev/null +++ b/src/kr_exercises/ch1/s1.5/get_put_char.c @@ -0,0 +1,22 @@ +/* Desc: Reads and prints inputted char + * Usage: name=get_put_char; gcc -o "$name" "$name".c; ./"$name"; + * Ref/Attrib: [0]: The C Programming Language, 2nd Edition, Section 1.5.1 + */ +#include + +/* copy input to output; 1st version */ + +int main(){ + int c; + + c = getchar(); + while(c != EOF) { + putchar(c); + c = getchar(); + }; + return 0; +}; + +/* Author: Steven Baltakatei Sandoval + * License: GPLv3+ + */ diff --git a/src/kr_exercises/ch1/s1.5/get_put_char2 b/src/kr_exercises/ch1/s1.5/get_put_char2 new file mode 100755 index 0000000..1a42622 Binary files /dev/null and b/src/kr_exercises/ch1/s1.5/get_put_char2 differ diff --git a/src/kr_exercises/ch1/s1.5/get_put_char2.c b/src/kr_exercises/ch1/s1.5/get_put_char2.c new file mode 100644 index 0000000..8f396cc --- /dev/null +++ b/src/kr_exercises/ch1/s1.5/get_put_char2.c @@ -0,0 +1,19 @@ +/* Desc: Reads and prints inputted char + * Usage: name=get_put_char2; gcc -o "$name" "$name".c; ./"$name"; + * Ref/Attrib: [0]: The C Programming Language, 2nd Edition, Section 1.5.1 + */ +#include + +/* copy input to output; 2nd version */ + +int main(){ + int c; + + while((c = getchar()) != EOF) + putchar(c); + return 0; +}; + +/* Author: Steven Baltakatei Sandoval + * License: GPLv3+ + */ diff --git a/src/kr_exercises/ch1/s1.5/getchar_eof_test b/src/kr_exercises/ch1/s1.5/getchar_eof_test new file mode 100755 index 0000000..d859d27 Binary files /dev/null and b/src/kr_exercises/ch1/s1.5/getchar_eof_test differ diff --git a/src/kr_exercises/ch1/s1.5/getchar_eof_test.c b/src/kr_exercises/ch1/s1.5/getchar_eof_test.c new file mode 100644 index 0000000..3ef4f5d --- /dev/null +++ b/src/kr_exercises/ch1/s1.5/getchar_eof_test.c @@ -0,0 +1,21 @@ +/* Desc: Test behavior of "getchar() not equal to EOF" + * Usage: name=getchar_eof_test; gcc -o "$name" "$name".c; ./"$name"; + * Ref/Attrib: [0]: The C Programming Language, 2nd Edition, Section 1.5.1 + */ +#include + +/* Reads a single character. Will display "output:0" if first + * character provided is EOF (e.g. "alt+D"). Otherwise, will display + * "output:1". + */ + +int main(){ + int output; + output = (getchar() != EOF); + printf("output:%d", output); + return 0; +}; + +/* Author: Steven Baltakatei Sandoval + * License: GPLv3+ + */ diff --git a/src/notes.tm b/src/notes.tm index c55e59e..67728a6 100644 --- a/src/notes.tm +++ b/src/notes.tm @@ -153,7 +153,8 @@ variable). - >Write one character at a time. + >Write one integer + character (e.g. ) at a time. >Used for printing formatted text to console. diff --git a/src/style-bk.ts b/src/style-bk.ts new file mode 100644 index 0000000..b4b8217 --- /dev/null +++ b/src/style-bk.ts @@ -0,0 +1,108 @@ + + + + +<\body> + <\active*> + <\src-title> + + + + + + + + + <\active*> + <\src-comment> + Style parameters. + + + + + + + + + + + + <\active*> + <\src-comment> + Macro definitions. + + + + \; + + |||||||||>>> + + >>>>>> + + > + |>>> + + >> + |>>> + + >>>>>> + + >>>>> + + + <\with|font-base-size|8> + <\verbatim> + + + + > + + >>>> + + >>> + + + <\vgroup> + <\verbatim-8pt> + <\with|font-base-size|8> + + + + + + \; + > + + <\active*> + <\src-comment> + Macro definitions: Monospace code blocks + + + + + <\wide-block> + | + <\shell-code> + + + >>> + + > + + + + + > + > + + |||||>>>>>>>> + + +<\initial> + <\collection> + + + \ No newline at end of file