home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Collection - Online Library - January 1996 / CKITOS2196.ISO / diskette / gg244090.dsk / unc.dsk / CHAPTER.04 / MATHB_M.C < prev    next >
C/C++ Source or Header  |  1993-06-25  |  1KB  |  36 lines

  1. /******************************************************************************/
  2. /* Module  : mathb_m.c                                                        */
  3. /* Purpose : Server manager code. Implements the add procedure that will be   */
  4. /*           called from the client mathb_c.                                  */
  5. /******************************************************************************/
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include "mathb.h"
  10.  
  11. /******************************************************************************/
  12. /* Procedure  : add                                                           */
  13. /* Purpose    : Add numv values passed in array value_a placing the sum in    */
  14. /*              total.                                                        */
  15. /******************************************************************************/
  16.  
  17. void add (
  18.    value_array_t value_a,
  19.    long numv,
  20.    long *total )
  21. {
  22.    int i;
  23.  
  24.    /* Display the parameters that have been passed.                           */
  25.    printf ( "Add has been called with numv = %d\n", numv );
  26.    for ( i = 0; i < numv; i++ )
  27.       printf ( "Value_a[ %d ] = %d\n", i, value_a[ i ] ); 
  28.  
  29.    /* Zero the accumulator.                                                   */
  30.    *total = 0;
  31.  
  32.    /* Add the values in the array of size numv placing the result in total.   */
  33.    for ( i = 0; i < MAX_VALUES && i < numv; i++ )
  34.       *total += value_a[ i ];
  35. }
  36.