Math Formulae

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Mon Dec 31 15:13:50 AEST 1990


In article <1990Dec29.073901.1810 at pegasus.com> tleylan at pegasus.com (Tom Leylan) writes:
> This doesn't have to be done in C necessarily but I know this is where
> all the smart programmers hang out...

Then your article is not appropriate for this group.

  [ how to make programs ``read'' like English ]
> For instance :  cost is 3% of total unless total is greater than $1000 then
> cost is 3% of the first $1000 and 2% of the balance.  A minimum charge of
> $20 applies.

cost = 0.03 * total;
if (total > 1000.00)
  cost = 0.03 * 1000.00 + 0.02 * (total - 1000.00);
if (cost < 20.00)
  cost = 20.00;

---Dan



More information about the Comp.lang.c mailing list