home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch4 / arraysum.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  772b  |  27 lines

  1. /*               arraysum.c
  2.  *
  3.  *   Synopsis  - Displays the value returned by the 
  4.  *               function addarray() with two different 
  5.  *               sets of parameters.
  6.  *
  7.  *   Objective - To provide a test program for the 
  8.  *               function addarray() written for an 
  9.  *               exercise. The answers should be 55 and 0.
  10.  */
  11.  
  12. /* Include Files */
  13. #include <stdio.h>
  14.  
  15. /* Function Prototypes */
  16. int addarray( int *, int );
  17.  
  18. int main( void )
  19. {
  20.      int array1[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
  21.          array2[4]  = { 0, 0, 0, 0 };
  22.  
  23.      printf( "The sum of the elements in array1 is %d.\n", addarray( array1, 10 ) );
  24.      printf( "The sum of the elements in array2 is %d.\n", addarray( array2, 4 ) );
  25.      return 0;
  26. }
  27.