home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_07_08 / v7n8056b.txt < prev    next >
Text File  |  1989-09-29  |  494b  |  23 lines

  1. *****Listing 2*****
  2.  
  3.  
  4. declare array to hold last N smaples.
  5. load array with first N samples
  6. set array_ptr to 1 
  7. calculate initial TOTAL for array
  8. calculate initial result ( TOTAL / N )
  9.  
  10. while sampling not finished
  11.      take sample
  12.      calculate TOTAL = TOTAL + sample - array(array_ptr)
  13.      array(array_ptr) = sample
  14.      result = TOTAL / n
  15.      store result
  16.  
  17.      if array_ptr < n
  18.         array_ptr = array_ptr + 1
  19.      else
  20.         array_ptr = 1
  21.      end if
  22. end while
  23.