Computer Science, asked by TbiaSamishta, 1 year ago

How the array elements are accessed?

Answers

Answered by nehadav98
1
Elements of an array are accessed by specifying the index ( offset ) of the desired element within square [ ] brackets after the array name. Arraysubscripts must be of integer type. ( int, long int, char, etc. ) ... ( The firstelement is at the beginning of thearray, and hence has zero offset. )
Answered by ChehraMasoom
0
Arrays have 0 as the first index not 1. In this example, mark[0]

If the size of an array is n, to access the last element, (n-1) index is used. In this example, mark[4]

Suppose the starting address of mark[0] is 2120d. Then, the next address, a[1], will be 2124d, address of a[2] will be 2128d and so on. It's because the size of a float is 4 bytes.


Similar questions