Hi, i need help answering a question from a past paper.
How do i write a function called "foo", that accepts a 1-dimensional array of double its size as an unsigned integer, passes back the root-mean-square of the array, and returns a bool.
I know how to write the body of the function, I just dont understand the definition part
The question is based on pseudocode, which is below if needed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
if array size ≤ 0
return: false
end if
declare: aVal (as double)
declare and initialise: sqrOfNums to 0 (as double)
declare and initialise: sumOfSqrs to 0 (as double)
for count = 0 to array size - 1 step 1
assign: aVal to value of current array element
assign: sqrOfNums to aVal x aVal
increment: sumOfSqrs by sqrOfNums
end for
assign: rms to sqrt(sumOfSqrs / array size)
return: true
I understand the basic form of a function definition, but when it says the function should accept a 1-dimensional array, pass back the RMS, and return a bool, how do i do this?