Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

template < typename T> long sumArray( const structArray<T> &janet ) { int sum =

ID: 3804900 • Letter: T

Question

template < typename T>
long sumArray( const structArray<T> &janet )
{
int sum = 0; // start our sum at 0
// iterate through each element in our array
for( int x = 0; x < janet.length; x++ ){
sum += janet.arrayData[ x ];
}
cout << "The sum is: " << sum << endl;
return sum;
}
template < typename T>
long meanArray (const structArray<T> &anne )
{
int sum = sumArray(structArray<T>, anne.length); // i dont have idea what wrong in this line the progam said that i have i primary expression before ','
return sum/anne.length ;// calculate the average
cout << "The mean is:" << meanArray << endl;
}

Explanation / Answer

Here is the modified code for you:

template < typename T>
long sumArray( const T &janet )
{
int sum = 0; // start our sum at 0
// iterate through each element in our array
for( int x = 0; x < janet.length; x++ ){
sum += janet.arrayData[ x ];
}
cout << "The sum is: " << sum << endl;
return sum;
}
template < typename T>
long meanArray (const T &anne )
{
int sum = sumArray(anne.length); // i dont have idea what wrong in this line the progam said that i have i primary expression before ','
int avg = sum/anne.length ;// calculate the average
cout << "The mean is:" << avg << endl;
}