I wrote the program below, but I want to change it so that it calculates after every number is entered.
Example:
Enter your number:
5
Total: 5
17
Total: 22
And so on.
Is there any way to do this?
Code:#include <stdio.h> int main() { int x int sum = 0; printf("Enter your numbers: <EOF> to stop. \n"); while(scanf(%d", &x) != EOF) sum += x; printf("\nThe total is: %d\n", sum); return 0; }