c langauge array

Using Arrays in C Language

In C language, you can declare an array by specifying the type of elements it will contain and the number of elements it will hold. Here's an example of how to declare an array of integers:

int myArray[5];  // Declares an array of 5 integers

You can also initialize the array at the time of declaration:

int myArray[5] = {1, 2, 3, 4, 5};  // Initializes the array with specified values

To access elements of the array, you can use square brackets and the index of the element (remember that array indexing starts at 0 in C):

int x = myArray[2];  // Accesses the third element of the array (index 2)

Arrays in C are powerful and versatile data structures that can be used in a wide variety of applications.