Arrays and Strings
Array Indexing
Array indexes select one stored element, starting from zero.
Array Indexing
array_indexing.c
#include <stdio.h>
int main(void) {
int scores[3] = {10, 20, 30};
int index = ;
int value = scores[index];
printf("score=%d\n", value);
return 0;
}
#include <stdio.h>
int main(void) {
int scores[3] = {10, 20, 30};
int index = ;
int value = scores[index];
printf("score=%d\n", value);
return 0;
}
#include <stdio.h>
int main(void) {
int scores[3] = {10, 20, 30};
int index = ;
int value = scores[index];
printf("score=%d\n", value);
return 0;
}
zero-based index
The first array element is at index `0`, the second at index `1`, and so on.
element access
`scores[index]` reads the element stored at that position.