How to define arrays in the C programming language?

In C language, arrays can be defined using the following syntax:

  1. Define an array within a function.
数据类型 数组名[数组大小];

For example:

int numbers[5]; // 定义了一个包含5个元素的整型数组
  1. Define an array globally.
数据类型 数组名[数组大小];

For example:

int numbers[5]; // 定义了一个包含5个元素的整型数组
  1. Initialize the array using an initialization list.
数据类型 数组名[] = {元素1, 元素2, ...};

For example:

int numbers[] = {1, 2, 3, 4, 5}; // 定义了一个包含5个元素的整型数组,并初始化为1、2、3、4、5

It should be noted that array indices in the C language start from 0. For example, in the array defined above with 5 elements, the index range of array elements is from 0 to 4.

bannerAds