int student_score[100];
float coordinate_x[10];
float coordinate_y[10];
int array1[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int array2[10] = {0};
int array3[5] = {10, 2}; // myArray will stores 10, 2, 0, 0, 0
int array4[] = {2, 4, 8};
char
type)str
has type char[4] and holds 'a', 'b', 'c', '\0'char str[] = "abc";
char str[3] = "abc"; // `str` has type char[3] and holds 'a', 'b', 'c'
int array[10];
for(int i = 0; i < 10; i++){
array[i] = i;
}
array[8] = 0;
int array[5] = {1, 2, 3, 4, 5}
:Address | Value | Array Form |
---|---|---|
0x00124400 | 1 | array[0] |
0x00124404 | 2 | array[1] |
0x00124408 | 3 | array[2] |
0x0012440C | 4 | array[3] |
0x00124410 | 5 | array[4] |
int score[5];
for(int i = 0; i < 5; i++){
scanf("%d", &score[i]);
}
for(int i = 0; i < 5; i++){
printf("%d\n", score[i]);
}
datatype name[ rowSize ][ columnSize ];
float matrix[5][3];
int map[4][5];
int myArray1[3][2] = { {1, 2} , {3, 4} , {5, 6} };
// or int myArray1[3][2] = {1, 2, 3, 4, 5, 6}
int myArray[3][2] = {{0}, {0}, {0}};
Take int array[2][3] = {1, 2, 3, 4, 5, 6}
as an example:
array[0][0] | array[0][1] | array[0][2] |
---|---|---|
array[1][0] | array[1][1] | array[1][2] |
Address | Value | Array Form |
---|---|---|
0x00124400 | 1 | array[0][0] |
0x00124404 | 2 | array[0][1] |
0x00124408 | 3 | array[0][2] |
0x0012440C | 4 | array[1][0] |
int map[4][5];
for( int i = 0; i < 4; i++) {
for( int j = 0; j < 5; j++) {
scanf(“%d”, &map[i][j]);
}
}
for( int i = 0; i < 4; i++) {
for( j = 0; j < 5; j++) {
printf(“%d\n”, map[i][j]);
}
}
-2 -3 4 -1 -2 1 5 -3
Maximum contiguous sum is 7