so I have miscellaneous functions being called in "main". The last function is suppose to return a value of "sum" but displays nothing. The function is working properly because I can cout the sum, the issue is the function isn't returning the sum to the console.......any idea's?
#include "std_lib_facilities.h"
void initArray(int list[], int listSize);
void fillArray(int list[], int listSize);
void printArray(int list[], int listSize);
int sumArray( int list[], int listSize);
int main()
{
int mylist[10], listSize = 10;
initArray(mylist, listSize);
fillArray(mylist, listSize);
printArray(mylist, listSize);
sumArray(mylist, listSize);
system("pause");
return(0);
}
void initArray(int list[], int listSize)
{
for (int i = 0; i < listSize; i++)
list[i] = 0; // this will initialize all elements of the array to 0.
}
void fillArray(int list[], int listSize)
{
for (int i = 0; i < listSize; i++)
cin >> list[i]; // this will assign each element an integer of the users choosing.
}
void printArray(int list[], int listSize)
{
for (int i = 0; i < listSize; i++)
cout << list[i] << ", ";
}
int sumArray(int list[], int listSize)
{//Function to find and return the sum of the
//elements of an int array. The parameter listSize
//specifies the number of elements to be added.
int index;
int sum = 0;
for (index = 0; index < listSize; index++)
sum = sum + list[index];
//cout << sum << endl;