|
|
1.1 root 1: #print
2: Using the "getnum" routine on "getnum.o", write a program
3: that reads a list of positive numbers and prints their sum. Stop reading
4: numbers when "getnum" returns a negative or zero value.
5: Compile and test your program; then type "ready".
6: #once #create Ref
7: 5 43 293 400 75 832 903 33
8: #once cp %s/getnum.o .
9: #user
10: a.out <Ref >xxx
11: grep 2584 xxx >/dev/null
12: #succeed
13: /* Read numbers and count */
14: main()
15: {
16: int s, n;
17:
18: s = 0;
19: while ((n=getnum()) > 0)
20: s += n;
21: printf("Sum is %d\n", s);
22: }
23: #log
24: #next
25: 14.2b 5
26: 15.1a 10
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.