Ask Question

Why should a function that accepts an array as argument also accept an argument specifying the array's size?

+3
Answers (1)
  1. 26 January, 12:38
    0
    An array is of fixed size. You'd set it to a certain size, but it may be the case that the array is not "full", as in you have not used all its "slots", thus you wouldn't want to waste time traversing through the entire array even if after a certain position all the slots are empty. Thus keeping track of the slots that are actually in use, will save time. Accepting an array's size as an argument will guarantee that say a loop only iterates the necessary number of time.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Why should a function that accepts an array as argument also accept an argument specifying the array's size? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers