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

Deliverable is to design an algorithm for a function that accepts an integer arr

ID: 3555618 • Letter: D

Question

Deliverable is to design an algorithm for a function that accepts an integer array as an argument and returns the total of values in the array. I need help to validate my understanding. this is my algorithm

// The First line in the program should be the function header

// What should be in the Function Header?

// enter the word Function followed by the DataType, Function Name, and (ParameterList)

Function(int array[ ], int size)

Integer total = 0

for i<-1 to size

sum<-sum+array[i]

return total

End function

Explanation / Answer

As we need to total the elements in the array we loop the array from 1st element to last and add each elemnt to the variable total and return total at the end. Please see below changes in bold

Function(int array[ ], int size)

Integer total = 0

for i=1 to size

total<-total+array[i]

return total

End function

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote