title: Completing my addarray () formula
body: <p>I apologize for my vagueness in advance-this is my first post and I can really use some help. </p>
  
  <p>The assignment is as follows:</p>
  
  <pre><code>/* Write a function named addarray() that returns the sum of the
  elements of an array of int values.  Your functions should take two
  parameters, the array and the number of elements in the array.  Make
  your function work with the following program; */
  
  /* arraysum.c
   * 
   * Synopsis - displays the value returned by the function addarray()
   * with 2 different sets of parameters.
   *
   * Objective - To provide a test program for the addarray() function.
   * Your answers should be 55 and 0.
   *
   */
  
  #include &lt;stdio.h&gt;
  
  int addarray(int [], int, int);
  
  void main() {
      int array1[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
      int array2[4] = {0, 0, 0, 0};
  
      printf("The sum of array1 = %d\n", addarray(array1, 0, 10));
      printf("The sum of array2 = %d\n", addarray(array2, 0, 4));
  }
  </code></pre>
  
  <p>This is my solution aid:</p>
  
  <pre><code>int addarray(int s[], int i, int n) {
      int sum = 0;
      for (i = 0; i &lt; n; i++) {
          sum += s[i];
      }
      return sum;
  }
  </code></pre>
  
  <p>I cant seem to figure out how to get the proper result. Any help would be appreciated.
  This is what I have completed so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int addarray(int array1[], int num_elements);
  void print_array(int array1[], int num_elements);
  
  void main(void)
  {
     int array1[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
     int sum;
  
     printf("\nArray:\n");
     print_array(array1, 10);
  
     sum = addarray(array1, 10);
     printf("The sum is %d\n .", sum);
  }
  int addarray(int array1[], int num_elements)
  {
     int i, sum=0;
     for (i=0; i&lt;num_elements; i++)
     {
       sum = sum + array1[i];
     }
     return(sum);
  }
  
  void print_array(int array1[], int num_elements)
  {
     int i;
     for(i=0; i&lt;num_elements; i++)
     {
       printf("%d ", array1[i]);
     }
     printf("\n");
  }
  </code></pre>
  
  <p>I cant figure out how to get a second array to be summed up.
  Such as Array2.</p>