Search⌘ K
AI Features

Arrays and Memory

Explore how arrays are stored in adjacent memory locations in C. Understand memory allocation for arrays, how to calculate their size, and how array elements can be accessed and manipulated.

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

...