[Solved] What is an array ?
What are its type ? 🤔Â
Types of arrays
- One-dimensional Array
- Multi-dimensional Array
One-dimensional Array:
Multi-dimensional Array:
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.
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:
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.
-
What is a primitive programming language ?
2 years ago
-
I want to print the sum of 5 + 15 but the output is 510 can someone help please ?
2 years ago
-
What is syntax error ?
2 years ago
-
What is an IDE ?
2 years ago
-
What is a garbage value ?
2 years ago
- 14 Forums
- 1,837 Topics
- 5,053 Posts
- 0 Online
- 1,079 Members