C++ One-dimensional arrays
A one-dimensional array in C++ is a group of variables of the same data type that are kept in close proximity to one another in memory. An array’s size is predetermined at the moment of declaration and cannot be altered later on.
Syntax for declaring a one-dimensional array:
data_type array_name[array_size];
Here, array name is the array’s name, array size is the array’s maximum element count, and data type is the kind of data the array will store. (such as int, float, char, etc.).

Example:
#include <iostream>
using namespace std;
int main() {
int arr[5] = {10, 20, 30, 40, 50};
// accessing and printing array elements
for (int i = 0; i < 5; i++) {
cout << arr[i] << " ";
}
return 0;
}
Output:
10 20 30 40 50
Another Example:
#include <iostream>
using namespace std;
int main() {
char str[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
// accessing and printing array elements
for (int i = 0; i < 6; i++) {
cout << str[i];
}
return 0;
}
Output:
Hello