0Pricing
C Academy · Lesson

Introduction to Arrays

Understand the concept of arrays, how they store data in contiguous memory locations, and how to manipulate them.

Introduction to Arrays is a free C Academy lesson on CoddyKit — lesson 1 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the C Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.

1

Introduction to Arrays

An array is a collection of variables of the same data type stored in contiguous memory locations.

In this lesson, you will learn:

  • How to declare and initialize arrays.
  • How arrays are stored in memory.
  • How to access and manipulate array elements.
Introduction to Arrays — illustration 1

2

Declaring an Array

Arrays are declared using square brackets [].

Example:

int numbers[5];

This creates an array that can store 5 integers.

3

Initializing an Array

Arrays can be initialized at the time of declaration:

int numbers[5] = {1, 2, 3, 4, 5};

Or, they can be initialized later:

numbers[0] = 10;

4

Accessing Array Elements

Array elements are accessed using an index (starting from 0).

Example:

int first = numbers[0];

This retrieves the first element of the array.

5

Example: Accessing Array Elements

This program demonstrates how to store and access elements of an array.

#include <stdio.h>

int main() {
    int numbers[5] = {10, 20, 30, 40, 50};
    printf("First element: %d\n", numbers[0]);
    printf("Second element: %d\n", numbers[1]);
    return 0;
}

6

Looping Through an Array

We can use a loop to iterate over an array:

for (int i = 0; i < 5; i++) { printf("%d ", numbers[i]); }

This prints all elements of the array.

7

Example: Looping Through an Array

This program prints all elements of an array using a loop.

#include <stdio.h>

int main() {
    int numbers[5] = {1, 2, 3, 4, 5};
    for (int i = 0; i < 5; i++) {
        printf("%d ", numbers[i]);
    }
    return 0;
}

8

9

Memory Representation of Arrays

Arrays are stored in contiguous memory locations.

Example:

int arr[3] = {10, 20, 30};

Memory Layout:

  • arr[0] → Address A
  • arr[1] → Address A + sizeof(int)
  • arr[2] → Address A + 2*sizeof(int)

10

Summary

In this lesson, you learned:

  • What arrays are and how they work.
  • How to declare, initialize, and access array elements.
  • How to loop through an array using a loop.

Next, we will explore multidimensional arrays in C!

Introduction to Arrays — illustration 10

Frequently asked questions

Is the “Introduction to Arrays” lesson free?

Yes — the full text of “Introduction to Arrays” is free to read here on the web, and the C Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the C Academy course, upgrade to CoddyKit PRO.

What will I learn in “Introduction to Arrays”?

Understand the concept of arrays, how they store data in contiguous memory locations, and how to manipulate them. You practise C Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start C Academy?

No prior experience is required. C Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 3, so you can start here or from the beginning and move at your own pace.

How long does the “Introduction to Arrays” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this C Academy lesson?

Yes. Every C Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Introduction to Arrays
  2. Multidimensional Arrays
  3. Strings in C
← Back to C Academy