One-dimensional and Multidimensional Arrays
Arrays in C++ are used to store multiple values of the same type in a single variable.
// One-dimensional array
int arr[5] = {1, 2, 3, 4, 5};
// Accessing elements
cout << arr[0]; // Output: 1
// Multidimensional array
int matrix[2][3] = {
{1, 2, 3},
{4, 5, 6}
};
cout << matrix[1][2]; // Output: 6
Arrays have fixed sizes and are indexed starting from 0.