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