/* Whilesum.c (c) Kari Laitinen http://www.naturalprogramming.com 2013-11-21 File created. 2013-11-21 Last modification. Warning: The behaviour of this program can be strange if you type in letters when it is asking whole numbers. Typing Ctrl-C helps often when a program does not terminate correctly. */ #include int main() { int integer_from_keyboard = -1 ; int sum_of_integers = 0 ; printf( "\n This program calculates the sum of integers you" "\n type in from the keyboard. By entering a zero you" "\n can terminate the program. \n\n" ) ; while ( integer_from_keyboard != 0 ) { printf( " Current sum: %8d Enter an integer: ", sum_of_integers ) ; scanf( "%d", &integer_from_keyboard ) ; sum_of_integers = sum_of_integers + integer_from_keyboard ; } }