/* ---------------------------------------------------------------------- // Figure 6.16: A cash register program. // Compute the sum of the prices entered by the user. // ---------------------------------------------------------------------- */ #include "tools.h" #define SENTINEL 0.0 void main( void ) { double price; /* The input variable */ double sum = 0.0; /* Accumulates the sum. */ printf( "\n Please enter prices. When finished, type 0 to quit.\n" " The total price will be printed.\n" "\t Price: " ); scanf ( "%lg", &price ); /* Read the first price. */ while (price != SENTINEL) { /* The sentinel value is 0.0 */ sum += price; printf( "\t Price: " ); scanf ( "%lg", &price ); } printf( "\n The total price is %g \n", sum ); bye(); }