#include <stdio.h>
int main(void) {
// Declare a two-dimensional array of integers with size 3x5
int array[3][5];
// Initialize the array with values
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 5; j++) {
array[i][j] = i * j;
}
}
// Access and print the values of the array
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 5; j++) {
printf("array[%d][%d] = %d\n", i, j, array[i][j]);
}
}
return 0;
}
int main(void) {
// Declare a two-dimensional array of integers with size 3x5
int array[3][5];
// Initialize the array with values
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 5; j++) {
array[i][j] = i * j;
}
}
// Access and print the values of the array
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 5; j++) {
printf("array[%d][%d] = %d\n", i, j, array[i][j]);
}
}
return 0;
}
This program declares a two-dimensional array of integers called array
with size 3x5 (3 rows and 5 columns), initializes the array with the product of the indices, and then prints the values of the array to the console.
Here is an example of the output of this program:
array[0][0] = 0
array[0][1] = 0
array[0][2] = 0
array[0][3] = 0
array[0][4] = 0
array[1][0] = 0
array[1][1] = 1
array[1][2] = 2
array[1][3] = 3
array[1][4] = 4
array[2][0] = 0
array[2][1] = 2
array[2][2] = 4
array[2][3] = 6
array[2][4] = 8
0 Comments