Notes / C / Arrays

Arrays in C — Revision Notes

A quick-reference cheat sheet: definition, syntax, example, common mistakes and an interview tip.

beginner 📖 2 min revision

Definition

📌 Arrays An array stores multiple values of the same type in one contiguous block of memory, accessed using an index starting at 0.The size of a C array is fixed once it's declared — it can't grow or shrink at runtime..

Syntax

syntax
type arrayName[size];
type arrayName[size] = {value1, value2, ...};

Example

c
#include <stdio.h>

int main() {
    int scores[5] = {90, 85, 70, 60, 95};
    for (int i = 0; i < 5; i++) {
        printf("%d ", scores[i]);
    }
    printf("\n");
    return 0;
}

Output

output90 85 70 60 95

Important Points

Common Mistakes

Interview Tip

🎯 Before your interview Know that arrays and pointers are closely related in C: arr[i] is really shorthand for *(arr + i).
Back to notes Read full lesson →