home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug150.arc / C-STUFF2.LBR / INVSALE.C < prev    next >
Text File  |  1979-12-31  |  768b  |  31 lines

  1.  
  2. main()                /* Inventory & sales *
  3.                  * example of types  */
  4.  
  5.     {
  6.     long total, stock;
  7.     unsigned sales;
  8.     float price, commission, cost, income;
  9.     double profit;
  10.     char type;
  11.  
  12.     sales = 45678;        /* item sold */
  13.     stock = 112502;        /* items on hand */
  14.     price = 42.50;        /* selling price */
  15.     cost = 19.95;        /* cost of item */
  16.     type = 'A';
  17.  
  18.     /* Calculate values */
  19.  
  20.     total = stock - sales;
  21.     income = price * sales;
  22.     profit = (price - cost) * sales;
  23.     commission = profit * 0.03;
  24.  
  25.     /* print answers */
  26.  
  27.     printf("Total inventory = %ld of type %c\n",total, type);
  28.     printf("On sales of %u items: profit = %f\n",sales, profit);
  29.     printf("Commissions at a rate of 0.03 = %f\n",commission);
  30.     }
  31.