/* * File: add10w.c * ------------- * This program adds a list of ten numbers, printing * the total at the end. Instead of reading the numbers * into separate variables, this program reads in each * number and adds it to a running total. * * Modified from "add10.c" by Jeff Tian to convert a "for" * loop into a "while" loop, and to show initialization and * combined increment/comparison. -- 9/15/98 */ #include #include "genlib.h" #include "simpio.h" main() { int i=0, value, total=0; printf("This program adds a list of ten numbers.\n"); while (i++ < 10) { printf(" ? "); value = GetInteger(); total += value; } printf("The total is %d\n", total); }