Summing an Array

  1. Write a function
    int sumArray(int nums[], int n),
    where nums is an integer array, and n is the size of the array.
  2. Return the sum of the numbers in the list.

Test the function with the following main() function.

int main()
{
    int array1[] = { 1, 3, 5, 7 };
    int array2[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    cout << sumArray(array1, sizeof(array1)/sizeof(array1[0]) ) << endl;
    cout << sumArray(array2, sizeof(array2)/sizeof(array2[0]) ) << endl;
    return 0;
}