+ 15

Why the array goes to 14 ¿? Зашто низ иде до 14 ¿?

https://code.sololearn.com/c77au7yPX6o1/?ref=app

10th Feb 2018, 4:03 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
3 ответов
+ 14
Code is different in "code vu0063 i vu0064" Код је другачији у " коду vu0063 i vu0064"
12th Feb 2018, 6:16 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
+ 2
for (int k = 0; k < 8; k++) { a[k] = k*2; } So this for loop wil run 8 times. Each time it will fill array with number -- k*2. k = 0, a[0] = 0 (0*2) k = 1, a[1] = 2 (1*2) k = 2, a[2] = 4 (2*2) k = 3, a[3] = 6 (3*2) k = 4, a[4] = 8 (4*2) k = 5, a[5] = 10 (5*2) k = 6, a[6] = 12 (6*2) k = 7, a[7] = 14 (7*2)
10th Feb 2018, 4:19 PM
Sad
Sad - avatar
+ 1
try to remove duplicate code. the second for loop can be deleted and simply insert Console.WriteLine(a[k]); after the a [k]=k*2; in the first for loop. works the same
3rd Mar 2018, 6:33 PM
Catalin Popinciuc
Catalin Popinciuc - avatar