We know that to store a set of elements we need to declare an array. But when we handle large set of elements there are some disadvantages of array. First of all the allocation of an array is static. Thus we need to mention the size of the array before compilation and this size cannot be changed throughout the program. We have to execute the program for fixed specified set of elements. But this is not possible in real life. Suppose, we want to write a program that will read student's name, roll number and marks of various subjects from user or from file and prepare a result sheet in descending order of total marks. If we write this program using an array, then it will be executed for fixed number of students. But generally in different classes or sections number of students varies. So, a single program is not sufficient. We need to write programs for each class/ section; though the program logic is same for all cases. Different program is required only for different array size. One solution is to declare an array which is sufficiently large. But this may lead to the problem of wastage of memory. Again in certain situation, if more elements need to store than the defined one, then it also faces the lack of memory problems. Sometimes it may happen that requirement may changes with the time. In these cases, old programs are needed to modify. Solution of these problems is Dynamic Allocation. But only Dynamic Allocation is not the solution. Sometimes it is not always possible to predict the size of the array at the very beginning of the program.
Review the options below to login to check your access.
Log in with your Cambridge Aspire website account to check access.
If you believe you should have access to this content, please contact your institutional librarian or consult our FAQ page for further information about accessing our content.