The question that is in my book says:
define a function with a single int type parameter n. the function should utilize a loop to read a loop to read in n integer values , then return the sum of these n numbers.
write the function definition only.
I thought of something like this but i don't know if im doing it right
1 2 3 4 5 6 7 8
int readInt(int n)
{
for( int i = 0; i<n; i++)
{
cout << i <<","<<endl;
}
return n;
}
int readInt (int n)
{ int sum = 0;
int val;
for (int i = 0; i<n; i++)
{ cin >> val; // Read in a value
sum += val; // Add the value to the running total
}
return sum;
}