Appearance
Initialize Array
c
// Syntax
dataType arrayName[arraySize] = {value1, value2, ...};
// Example
int numbers[5] = {1, 2, 3, 4, 5};java
// Syntax
dataType[] arrayName = {value1, value2, value3, ...};
// Example
int[] numbers = {1, 2, 3, 4, 5};- dataType: The type of data the array will hold (e.g., int, float, string, etc.).
- arrayName: The name of the array you're declaring.
- arraySize (in C/C++): The size or number of elements the array will contain.
- {value1, value2, ...}: The initial values you want to assign to the array elements. This part is optional; you can declare an array without initializing it immediately.