Array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Array

as we know, if we entered numbers less than allocated size of array then compiler will show remaining positions are zero. but at run time we always have to fill all memory location. suppose if I declare size of array 10 and wanna put only 5 numbers then what I have to do??

2nd Sep 2018, 11:06 AM
Abhishek Shailendra Khandare
Abhishek Shailendra Khandare - avatar
2 Answers
+ 1
Abhishek Shailendra Khandare , nothing wrong if you assign 5 values for array of size 10.... just make sure that you don't access those unassigned values as it might give you unexpected answers... still compiler may initialize other 5 values to 0.... why you are so much worried about those values if you are concerned for first 5 values... just go with array of size 5...
2nd Sep 2018, 12:01 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
thx sir
2nd Sep 2018, 6:57 PM
Abhishek Shailendra Khandare
Abhishek Shailendra Khandare - avatar