Thus, the following program computes trade values as
you type price-per-sharenumber-of-shares pairs; it stops when you type
the control-d
keychord:
#includedouble trade_price (double p, int n) { return p * n; } main ( ) { double price; int number; while (2 == scanf ("%lf%i", &price, &number)) printf ("The total price of the trade is %f.\n", trade_price (price, number)); } --- Data --- 2.5 500 7.5 500 --- Result --- The total price of the trade is 1250.000000. The total price of the trade is 3750.000000.