Arrays (62??) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Arrays (62??)

In this example, value 42 is assigned to the third element of the array. What happens to the 62? Does it get shifted to the fourth element as there is no set maximum in term of element values? int b[] = {11, 45, 62, 70, 88}; b[2] = 42;

25th Nov 2019, 9:48 PM
Anthony Bankam Jr
Anthony Bankam Jr - avatar
3 Answers
+ 8
Anthony Bankam Jr 62 will be overwrite with 42 and rest element are remain same no shifting it's just vanishing the 62 and writing over 62 with value 42
25th Nov 2019, 10:13 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
Thanks
25th Nov 2019, 10:20 PM
Anthony Bankam Jr
Anthony Bankam Jr - avatar
+ 1
Anthony Bankam Jr, if you don't specify the length of an array, it will be just long enough to hold the values you initialize it with.
25th Nov 2019, 10:26 PM
HonFu
HonFu - avatar