Arrays and Memory

Learn how array elements are stored in memory.

Ordinary variables in memory

i, j, k, l, and m are ordinary variables. They may or may not be stored in adjacent memory locations. This is indicated in the output of the first printf( ).

#include<stdio.h>

int main() {
    int i =3, j = 20, k = -5, l = 7, m =11;
    // Prints address of ordinary variables
    printf("%u %u %u %u %u\n", &i, &j, &k, &l, &m);

}

📝 Note: You might get different addresses each time you run the program given above.

Array elements in memory

...
Access this course and 1400+ top-rated courses and projects.