It is necessary to declare size of array?how much memory is allocated if size isnt declared? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

It is necessary to declare size of array?how much memory is allocated if size isnt declared?

is array wuthout size declaration makes program slow? why we need to declare size of array as its run without declaring it then why linked lists are invented?

19th Jan 2017, 5:28 AM
Suhas Patil
Suhas Patil - avatar
3 Answers
+ 6
Yes you need to provide the array size at the time of declaration. How will it work when you haven't given the array size except in the case e.g: int arr[]={1,2,3} then the size is automatically computed by the compiler. One reason for developing linked list is that once an array is declared, its size cannot be changed unless its dynamically created, so an array size cannot be reduced or increased easily while in linked list the size is not fixed.
19th Jan 2017, 11:23 AM
Saumya
Saumya - avatar
+ 4
Its better to use List if you don't have a fixed index to an array.
19th Jan 2017, 5:32 AM
Nahuel
Nahuel - avatar
0
how much memory allocated if size is not declared?
19th Jan 2017, 5:33 AM
Suhas Patil
Suhas Patil - avatar