summaryrefslogtreecommitdiff
path: root/usr.bin/learn/lib/C/L5.2b
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/learn/lib/C/L5.2b')
-rw-r--r--usr.bin/learn/lib/C/L5.2b28
1 files changed, 28 insertions, 0 deletions
diff --git a/usr.bin/learn/lib/C/L5.2b b/usr.bin/learn/lib/C/L5.2b
new file mode 100644
index 00000000000..0fce2989e27
--- /dev/null
+++ b/usr.bin/learn/lib/C/L5.2b
@@ -0,0 +1,28 @@
+#print
+(Section 1.5)
+Write a program which reads a character from its
+input and tests whether that character is larger than
+100 in numeric value. If so, read two more
+characters, and print the value of the second of them
+in octal. Compile and test your program, then type "ready".
+#once #create Ref1
+u V has value 126
+#once #create Ref2
+. V should not be processed
+#user
+a.out <Ref1 >test1
+a.out <Ref2 >test2
+grep 126 test1 >/dev/null && cmp -s test2 /dev/null
+#succeed
+One way:
+
+main()
+{
+ if (getchar() > 100) {
+ getchar();
+ printf("%o\n", getchar());
+ }
+}
+#log
+#next
+5.1c 10