Array
Array
ARRAY
C++ ARRAY
In C++, an array is a data
structure that is used to store
multiple values of similar data
types in a contiguous memory
location.
SYNTAX: data_type array_name[size_of_array];
EXAMPLE: int arr[5];
Access Array
Elements
You can access elements of an array by indices.
Suppose you declared an array mark as above. The first element
is mark[0], the second element is mark[1] and so on.
Types of Arrays in C++
There are 3 types of an array in C++ :
• One-dimensional array
• Two-dimensional array
• Three-dimensional array
• m: row number
• n : column number
Three-Dimensional Array:
The 3D array uses three dimensions. There are three indices—the row index, column
index, and depth index to uniquely identify each element in a 3D array.
Syntax:
void pass(int arr[10])
{
body
}
Syntax:
void pass(int
arr[])
{
body
}
Output:
The element is 1.
The element is 3.
The element is 9.
The element is 4.
The element is 5.
THANK YOU