home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / RXCALC.ZIP / PROGRAM3.CAL < prev    next >
Text File  |  1991-05-15  |  965b  |  20 lines

  1. /* Rexx Calculator program 3 key - average of memory registers       */
  2. parse arg num                          /* get the count of memories  */
  3. numeric digits CalcPrecision()         /* set current precision      */
  4. numeric form value CalcForm()          /* set current form           */
  5.  
  6. if \datatype(num, 'Whole')             /* must be whole number       */
  7.   then return 'Error'                  /* return error indicator     */
  8.  
  9. if num < 1 | num >50                   /* valid for counter          */
  10.   then return 'Error'                  /* return error indicator     */
  11.  
  12. accumulator = 0                        /* start at zero              */
  13.  
  14. do i = 1 to num                        /* loop for given number      */
  15.   'GET' i 'REGISTER'                   /* get next register          */
  16.   accumulator = accumulator + register /* add to total               */
  17. end
  18.  
  19. return accumulator / num               /* return the average         */
  20.