FIND THE ANSWERS

Write a program to sum integers entered interactively using while loop.in c?

Answer this question

  • Write a program to sum integers entered interactively using while loop.in c?


Answers

Answer #1 | 23/12 2013 00:52
I would just use Excel if I needed to sum some numbers.
Answer #2 | 23/12 2013 01:30
Do you mean finding the sum each time a new integer is entered? If so, then try this: #include int main() { int num; long sum; while (scanf("%ld", &sum) == 1) { printf("%ld\n", sum); while (scanf("%d", &num) == 1) { sum += num; printf("%ld\n", sum); } } return(0); } Press ctrl + D (On Linux) or ctrl + Z (on Windoze) to reset the sum. Press it twice to close the program.

Possible answer