Notifications
Clear all

[Solved] What is an array ?

3 Posts
4 Users
7 Likes
661 Views
0
Topic starter

What are its type ? 🤔 

Topic Tags
3 Answers
2

Types of arrays

  • One-dimensional Array
  • Multi-dimensional Array

One-dimensional Array:

Types of arrays -One dimensional array

Multi-dimensional Array:

  1. Types of arrays -Two dimensional array
  2. Types of arrays -3 dimensional array
3

An array is a collection of items of same data type stored at contiguous memory locations. 

This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array). The base value is index 0 and the difference between the two indexes is the offset.

2

The array is a data structure where values or items are placed in a linear order, which means the memory assigned to each item is contiguous. The data type of an array is the same for all the elements present in it.

With the contiguous memory allocation, it becomes easier to find out the memory location of any element in the array by just knowing the first memory location and adding the offset.

For Example:

What is Array

In the above example, we have an integer array, and the memory locations are contiguous, where each integer takes 4 bytes, and the starting address is 4000.

We cannot increase or decrease the size of an array dynamically once it is declared. The memory allocation is static in most of the languages, so we have to declare the array size at the time of array declaration.

Share: