Here is a statical array:
int arr[50]; /* 50 integers in the array */
/* setting some values */
arr[0] = 1;
arr[1] = 2;
...
int matrix[10][10]; /* we have a matrix 10 x 10 of integers */
/* setting some values */
matrix[0][0] = 1;
matrix[1][1] = 2;
matrix[3][5] = 3;
...
You can initialize array at the time of creation:
int arr[3] = { 0, 1, 3 };
/* or could do like this */
int arr[] = { 0, 1, 2, 3, 4, 5 };
int matrix[2][4] = { 0, 0, 0, 01, 1, 1, 1};
/* is the same as: */
int matrix[2][4] = { { 0, 0, 0, 0 }, { 1, 1, 1, 1} };
C Arrays are no limited only to one and two dimensional arrays, you can define N-dimensional arrays too.
int cube[3][3][3]; /* here we have a cube 3 x 3 x 3*/
There are dynamic arrays too, but that requires knowledge of memory management and pointers. There are some links that will explain arrays in C more detailed.
Copyright © 2026 eLLeNow.com All Rights Reserved.