/*-------------------------------------------------------------------*/ /* sumarray.c */ /*-------------------------------------------------------------------*/ #include #define 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); for (iIndex = 0; iIndex < iCount; iIndex++) scanf("%d", &piNumbers[iIndex]); iSum = 0; for (iIndex = 0; iIndex < iCount; iIndex++) iSum += piNumbers[iIndex]; printf("The sum is %d.\n", iSum); return 0; }