/*------------------------------------------------------------------*/ /* sumarrayflat.c */ /* Author: Bob Dondero */ /*------------------------------------------------------------------*/ #include enum {ARRAYSIZE = 100}; static int piNumbers[ARRAYSIZE]; static int iIndex; static int iCount; static int iSum; int main(int argc, char *argv[]) /* Read up to ARRAYSIZE integers from stdin, and write to stdout the sum of those integers. */ { printf("How many integers? "); scanf("%d", &iCount); iIndex = 0; loop1: if (iIndex >= iCount) goto loopend1; scanf("%d", &piNumbers[iIndex]); iIndex++; goto loop1; loopend1: iSum = 0; iIndex = 0; loop2: if (iIndex >= iCount) goto loopend2; iSum += piNumbers[iIndex]; iIndex++; goto loop2; loopend2: printf("The sum is %d.\n", iSum); return 0; }