Arrays are a block of items of the same type, stored side by side.
Direct answer
A C array is a fixed-size list of items of the same type, indexed from 0. Declare it with type name[size], access items with name[index] and loop with a for loop. C does not check bounds, so you must keep indexes within range.
Example
#include <stdio.h>
int main(void) {
int scores[5] = {90, 85, 70, 60, 100};
int total = 0;
for (int i = 0; i < 5; i++) {
total += scores[i];
}
printf("Average: %d\n", total / 5);
return 0;
}
Length of an array
int n = sizeof(scores) / sizeof(scores[0]);
This works in the function where the array was declared. When you pass an array to a function, it becomes a pointer, so pass the length too.
Passing to functions
void print_all(int arr[], int n) {
for (int i = 0; i < n; i++) printf("%d ", arr[i]);
}
Pitfalls
- Reading or writing past the end causes undefined behaviour.
- Arrays do not know their own length.
Where Teyro fits
Teyro's C for Beginners course turns this into short lessons you can play in a few minutes a day. It has 78 lessons, and you can start free.
The bottom line
Keep track of size and stay in bounds.



