summaryrefslogtreecommitdiff
path: root/21_read_rec1
diff options
context:
space:
mode:
authorHaidong Ji2022-04-15 15:51:30 -0500
committerHaidong Ji2022-04-15 15:51:30 -0500
commit442a49ad5a48d417345959b903ae6a6d32d55759 (patch)
treec7127bb497e5e439018b1915e0136eec2c9cb124 /21_read_rec1
Great C programming funHEADmaster
Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git
Diffstat (limited to '21_read_rec1')
-rw-r--r--21_read_rec1/.gitignore2
-rw-r--r--21_read_rec1/README4
-rw-r--r--21_read_rec1/answer.txt4
-rw-r--r--21_read_rec1/grade.txt5
-rw-r--r--21_read_rec1/test.c28
5 files changed, 43 insertions, 0 deletions
diff --git a/21_read_rec1/.gitignore b/21_read_rec1/.gitignore
new file mode 100644
index 0000000..08001c7
--- /dev/null
+++ b/21_read_rec1/.gitignore
@@ -0,0 +1,2 @@
+test
+Makefile
diff --git a/21_read_rec1/README b/21_read_rec1/README
new file mode 100644
index 0000000..bebd9b8
--- /dev/null
+++ b/21_read_rec1/README
@@ -0,0 +1,4 @@
+Execute the code in test.c (by hand). Write the resulting output in a file
+called "answer.txt".
+
+Check your work, and submit as usual.
diff --git a/21_read_rec1/answer.txt b/21_read_rec1/answer.txt
new file mode 100644
index 0000000..d83d20b
--- /dev/null
+++ b/21_read_rec1/answer.txt
@@ -0,0 +1,4 @@
+a=29, b=7
+a=2, b=9
+a=0, b=2
+297
diff --git a/21_read_rec1/grade.txt b/21_read_rec1/grade.txt
new file mode 100644
index 0000000..27dbba2
--- /dev/null
+++ b/21_read_rec1/grade.txt
@@ -0,0 +1,5 @@
+Grading at Fri 29 Oct 2021 02:12:30 AM UTC
+Your file matched the expected output
+Your output matched what we expected
+
+Overall Grade: A
diff --git a/21_read_rec1/test.c b/21_read_rec1/test.c
new file mode 100644
index 0000000..52fd4e4
--- /dev/null
+++ b/21_read_rec1/test.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void printDigits(int x) {
+ if (x == 0) {
+ printf("0");
+ }
+ else if (x < 0) {
+ printf("-");
+ printDigits(-x);
+ }
+ else {
+ int a = x/10;
+ int b = x %10;
+ printf("a=%d, b=%d\n",a,b);
+ if (a != 0) {
+ printDigits(a);
+ }
+ printf("%d",b);
+ }
+}
+
+
+int main(void) {
+ printDigits(297);
+ printf("\n");
+ return EXIT_SUCCESS;
+}