“Mengapa indeks array dimulai dari 0” Kode Jawaban

Mengapa indeks array dimulai dari 0

Array address: 0x7ffe9472bad0
Array[0] = 0x7ffe9472bad0
Array[1] = 0x7ffe9472bad4
Array[2] = 0x7ffe9472bad8
...

The first element and the array itself points to the same memory location, 
so it is 0 elements away from the location of the array itself.

// https://albertkoz.com/why-does-array-start-with-index-0-65ffc07cbce8
shahul

Mengapa indeks array dimulai dari 0

An array arr[i] is interpreted as *(arr+i). Here, arr denotes the address of the first array element or the 0 index element. So *(arr+i) means the element at i distance from the first element of the array. So array index starts from 0 as initially i is 0 which means the first element of the array.
Lively Lion

Jawaban yang mirip dengan “Mengapa indeks array dimulai dari 0”

Pertanyaan yang mirip dengan “Mengapa indeks array dimulai dari 0”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya