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

Why?

need array with size 9, true answer int array[8], why it's wrong answer? we start numeration from zero, 012345678, this 9.

20th Jul 2017, 4:49 PM
Sergey TD
Sergey TD - avatar
2 Answers
+ 4
int array[8] has a size of 8. Remember that 8 itself is not included and the index goes like 0,1,2,3,4,5,6,7.
20th Jul 2017, 4:53 PM
Dennis
Dennis - avatar
0
declaring the array you start from 1, accessing it you start from index 0 int a[9]={0,1,2,3,4,5,6,7,8}; cout << a[3]; //3 cout << a[9]; //error
20th Jul 2017, 5:42 PM
Andrés04_ve
Andrés04_ve - avatar