How do you assign values to a two-dimensional array in C language?
In the C language, it is possible to assign values to a two-dimensional array using loops. For example, to assign values to a 3×3 two-dimensional array, you can use the following code:
int arr[3][3];
int count = 1;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
arr[i][j] = count;
count++;
}
}
The code above will assign the two-dimensional array arr to a value:
1 2 3
4 5 6
7 8 9