/* * Program to compute sum of integers entered as input (any number of them), * using recursion. */ #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 n; if (scanf("%d", &n) == 1) { /* add this input to sum of remaining inputs */ return n + sum(); } else { /* non-integer input */ return 0; } }