/* * Program to compute sum of integers entered as input (any number of them), * using a loop. */ #include int main(void) { printf("enter integers, anything else to stop\n"); int sum = 0; int input; /* * somewhat cryptic but C-idiomatic: * tries to read a value into input as part of evaluating condition * if it succeeds, loop continues; otherwise it stops */ while (scanf("%d", &input) == 1) { sum += input; } printf("sum is %d\n", sum); return 0; }