46.2k views
4 votes
Suppose you want to write a program that will read a list of numbers from a user, place them into an array and then compute their average. How large should you make the array? It must be large enough to hold all the values, but how many

User Mourodrigo
by
5.8k points

1 Answer

5 votes

Answer:

The size of the array should be decided at run-time. In other words it is better to use dynamic size array.

Step-by-step explanation:

The size of the array will totally depend on the number of items in the list. Since the number of items in the list is not known. Therefore using a fixed size is not a good option.

A fixed size array can either be too small or too small for the list of values. This can result in lots of memory loss.

Thus the array size should be decided at run-time by the program.

User Kasinath Kottukkal
by
5.2k points