![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In the following program, a trade
object,
t
, is created; values are assigned to the price and number structure
variables; and the trade
object's price is computed by a function
named trade_price
.
#includestruct trade {double price; int number;}; double trade_price (double p, int n) {return p * n;} main ( ) { double price; int number; struct trade t; while (2 == scanf ("%lf%i", &price, &number)) { t.price = price; t.number = number; printf ("The total value of the trade is %f.\n", trade_price (t.price, t.number)); } } --- Data --- 2.5 500 5.0 1000 --- Result --- The total value of the trade is 1250.000000. The total value of the trade is 5000.000000.