Set array values at declaration using curly braces. Write int nums[5] = {10, 20, 30, 40, 50}; and each element gets its corresponding value. First value goes to index 0, second to index 1, and so on.
The values inside the braces must match the array's type. For an int array, provide integers. For a double array, provide decimals or integers that convert automatically. If you provide fewer values than the size, remaining elements get zero.
If you provide more, the compiler gives an error. The list length must not exceed the declared size.