Types of Arrays
There are majorly 4 types of arrays
1. Fixed Size Array
2. Dynamic Sized Array
3. 1-Dimensional Array
4. Multi-Dimensional Array
Classification of Types of Arrays
However, these array types can be broadly classified in two ways:
- On the basis of Size
- On the basis of Dimensions

Table of Content
Types of Arrays on the basis of Size:
1. Fixed Sized Arrays:
We cannot alter or update the size of this array. Here only a fixed size (i,e. the size that is mentioned in square brackets []) of memory will be allocated for storage. In case, we don't know the size of the array then if we declare a larger size and store a lesser number of elements will result in a wastage of memory or we declare a lesser size than the number of elements then we won't get enough memory to store all the elements. In such cases, static memory allocation is not preferred.
// Method 1 to create a fixed sized array.
// Here the memory is allocated at compile time.
int arr[5];
// Another way (creation and initialization both)
int arr2[5] = {1, 2, 3, 4, 5};
// Method 2 to create a fixed sized array
// Here memory is allocated at run time (Also
// known as dynamically allocated arrays)
int *arr = new int[5];
// Method 1 to create a fixed sized array.
// Here the memory is allocated at compile time.
int arr1[5];
// Another way (creation and initialization both)
int arr2[5] = {1, 2, 3, 4, 5};
// Method 2 to create a fixed sized array
// Here memory is allocated at run time (Also
// known as dynamically allocated arrays)
int *arr = (int*)malloc(n * sizeof(int));
// Fixed sized array examples
int[] arr1 = new int [5];
// Another way (Array creation and
// initialization both)
int[] arr2 = {1, 2, 3, 4, 5};
import array
# Static Array
arr = array.array('i', [1, 2, 3, 4, 5])
// Fixed sized array examples
int[] arr1 = new int [5];
// Another way (Array creation and
// initialization both)
int[] arr2 = {1, 2, 3, 4, 5};
2. Dynamic Sized Arrays:
The size of the array changes as per user requirements during execution of code so the coders do not have to worry about sizes. They can add and removed the elements as per the need. The memory is mostly dynamically allocated and de-allocated in these arrays.
#include<vector>
// Dynamic Integer Array
vector<int> v;
// C does not seem to support
// dynamic sized arrays as of now
// Dynamic Integer Array
ArrayList<Integer> arr = new ArrayList<>();
# Dynamic Array
arr = []
// Similar to Java
ArrayList myList = new ArrayList();
// Dynamic Sized Array
let arr = new Array();
Types of Arrays on the basis of Dimensions
There are majorly three types of arrays on the basis of dimensions:
1. One-dimensional array (1-D arrays):
You can imagine a 1d array as a row, where elements are stored one after another.

Syntax for Declaration of Single Dimensional Array
Below is the syntax to declare the single-dimensional array
data_type array_name[array_size];
where,
- data_type: is a type of data of each array block.
- array_name: is the name of the array using which we can refer to it.
- array_size: is the number of blocks of memory array going to have.
For Example
int nums[5];
2. Two-dimensional (2D) array:
Multidimensional arrays can be considered as an array of arrays or as a matrix consisting of rows and columns.

Syntax for Declaration of Two-Dimensional Array
Below is the syntax to declare the Two-dimensional array
data_type array_name[sizeof_1st_dimension][sizeof_2nd_dimension];
where,
- data_type: is a type of data of each array block.
- array_name: is the name of the array using which we can refer to it.
- sizeof_dimension: is the number of blocks of memory array going to have in the corresponding dimension.
For Example
int nums[5][10];
3. Three-dimensional array:
A 3-D Multidimensional array contains three dimensions, so it can be considered an array of two-dimensional arrays.

Syntax for Declaration of Three-Dimensional Array
Below is the syntax to declare the Three-dimensional array
data_type array_name[sizeof_1st_dimension][sizeof_2nd_dimension][sizeof_3rd_dimension];
where,
- data_type: is a type of data of each array block.
- array_name: is the name of the array using which we can refer to it.
- sizeof_dimension: is the number of blocks of memory array going to have in the corresponding dimension.
For Example
int nums[5][10][2];