home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Microsoft Programmer's Library 1.3
/
Microsoft-Programers-Library-v1.3.iso
/
sampcode
/
qc_prog
/
chap07
/
sadd.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
NeXTSTEP
RISC OS/Acorn
UTF-8
Wrap
C/C++ Source or Header
|
1988-04-05
|
424 b
|
21 lines
/* sadd.c -- a small adding machine that illustrates */
/* the need for array bounds checking. */
main()
{
int offset = 0, i, result = 0;
int stack[3];
while (scanf("%d", &stack[offset]) == 1)
{
++offset;
}
for (i = 0; i < offset; ++i)
{
result += stack[i];
}
printf("-------------\n");
printf("%d\n", result);
}