summaryrefslogtreecommitdiff
path: root/usr.bin/learn/lib/C/L5.1c
diff options
context:
space:
mode:
authorIan Darwin <ian@cvs.openbsd.org>1998-09-28 16:01:29 +0000
committerIan Darwin <ian@cvs.openbsd.org>1998-09-28 16:01:29 +0000
commite9be7faad5fbf61edcad3700142615e315e407bc (patch)
tree5f3febafdfca4e38b83cbc129c87aefdece9ae70 /usr.bin/learn/lib/C/L5.1c
parent0436a5b6c19a613da918536b89a49cbcb38a2e4e (diff)
import BTL learn(1) lessons/C
Diffstat (limited to 'usr.bin/learn/lib/C/L5.1c')
-rw-r--r--usr.bin/learn/lib/C/L5.1c31
1 files changed, 31 insertions, 0 deletions
diff --git a/usr.bin/learn/lib/C/L5.1c b/usr.bin/learn/lib/C/L5.1c
new file mode 100644
index 00000000000..44c3f59060c
--- /dev/null
+++ b/usr.bin/learn/lib/C/L5.1c
@@ -0,0 +1,31 @@
+#print
+(Section 1.5)
+Write a program which reads one character from
+its input; if that character is ? it prints "yes",
+otherwise it prints "no".
+Compile it, test it, and then type ready.
+#once #create Ref1
+? is here
+#once #create Ref2
+no ? at beginning
+#user
+a.out <Ref1 >test1
+a.out <Ref2 >test2
+grep yes test1 >/dev/null && grep no test2 >/dev/null
+#succeed
+This is one possible solution
+
+main()
+{
+ if (getchar() == '?')
+ printf("yes\n");
+ else
+ printf("no\n");
+}
+
+The indenting and general formatting of C programs
+should be done so you make the structure clear,
+like the code above.
+#log
+#next
+5.1d 10