/* * Program to compute sum of integers entered as input (any number of them), * using a loop. */ #include int sum(void); int main(void) { printf("enter integers, anything else to stop\n"); printf("sum is %d\n", sum()); return 0; } /* * compute and return sum of integers from stdin, stopping when anything else * is entered */ int sum(void) { int sum = 0; int n; while (scanf("%d", &n) == 1) { sum += n; } return sum; }