Question: Sum Create a function that calculates the sum of all numbers of an integer array. int sum ( const int array [ ] , const
Sum
Create a function that calculates the sum of all numbers of an integer array.
int sumconst int array const int size
Example of pseudocode
function sum
INPUT: integer array, size
OUTPUT: sum
sum
for i from to size
sum sum arrayi
end for
return sum
Recursive sum
Create a function that calculates the sum of all numbers of an integer array recursively.
int recursiveSumconst int array const int size, const int position
Example of pseudocode
function recursiveSum
INPUT: integer array, size, position to analyze
OUTPUT: partial sum
if position size
return
else
return arrayposition recursiveSumarraysize,position
end if
Recursive Max
Create a function that determine recursively the maximum value of the numbers of an integer array.
int recursiveMaxconst int array const int size, const int position
Example of pseudocode
function recursiveMax
INPUT: integer array, size, position to analyze
OUTPUT: partial max
if position size
return INTMIN
else
partialMax recursiveMaxarraysize,position
if arrayposition partialMax
return arrayposition
else
return partialMax
end if
end if
See INTMIN definition.
Recursive Min
Create a function that determine recursively the minimum value of the numbers of an integer array.
int recursiveMinconst int array const int size, const int position
In the main function
Create an integer array of at least elements, and display its elements.
Test the four functions using that array and display the results results.
Example of expected output
Recursive functions!
Sum:
Recursive sum:
Recursive max:
Recursive min: Sum
Create a function that calculates the sum of all numbers of an integer array.
int sumconst int array const int size
Example of pseudocode
function sum
INPUT: integer array, size
OUTPUT: sum
sum
for i from to size
sum sum arrayi
end for
return sum
Recursive sum
Create a function that calculates the sum of all numbers of an integer array recursively.
int recursiveSumconst int array const int size, const int position
Example of pseudocode
function recursiveSum
INPUT: integer array, size, position to analyze
OUTPUT: partial sum
if position size
return
else
return arrayposition recursiveSumarraysize,position
end if
Recursive Max
Create a function that determine recursively the maximum value of the numbers of an integer array.
int recursiveMaxconst int array const int size, const int position
Example of pseudocode
function recursiveMax
INPUT: integer array, size, position to analyze
OUTPUT: partial max
if position size
return INTMIN
else
partialMax recursiveMaxarraysize,position
if arrayposition partialMax
return arrayposition
else
return partialMax
end if
end if
See INTMIN definition.
Recursive Min
Create a function that determine recursively the minimum value of the numbers of an integer array.
int recursiveMinconst int array const int size, const int position
In the main function
Create an integer array of at least elements, and display its elements.
Test the four functions using that array and display the results results.
Example of expected output
Recursive functions!
Sum:
Recursive sum:
Recursive max:
Recursive min:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
