diff options
author | Ian Darwin <ian@cvs.openbsd.org> | 1998-09-28 16:01:29 +0000 |
---|---|---|
committer | Ian Darwin <ian@cvs.openbsd.org> | 1998-09-28 16:01:29 +0000 |
commit | e9be7faad5fbf61edcad3700142615e315e407bc (patch) | |
tree | 5f3febafdfca4e38b83cbc129c87aefdece9ae70 /usr.bin/learn/lib/C/L19.1a | |
parent | 0436a5b6c19a613da918536b89a49cbcb38a2e4e (diff) |
import BTL learn(1) lessons/C
Diffstat (limited to 'usr.bin/learn/lib/C/L19.1a')
-rw-r--r-- | usr.bin/learn/lib/C/L19.1a | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/usr.bin/learn/lib/C/L19.1a b/usr.bin/learn/lib/C/L19.1a new file mode 100644 index 00000000000..21e46af064b --- /dev/null +++ b/usr.bin/learn/lib/C/L19.1a @@ -0,0 +1,29 @@ +#print +Write a subroutine which counts the number of times it has +been called and returns that count each time. Name it +"count()". Write it on a file named "count.c". Compile +and test it; type "ready" when happy. +#once #create Ref +23080 +#once #create tzaqc.c +main() { + int i; + for (i = 0; i < 23079; i++) + count(); + printf("%d\n", count()); +} +#user +cc tzaqc.c count.o +a.out >value +#cmp value Ref +#succeed +/* one way */ +count() +{ + static int n = 0; + return(++n); +} +#log +#next +30.1a 10 +20.1a 5 |