Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Two Dimensional Arrays | Data
C Basics

Two Dimensional ArraysTwo Dimensional Arrays

Two-dimensional arrays are a bit like tables — think of them as arrays within arrays, with rows and columns.

Declaring a two-dimensional array requires an extra set of square brackets:

Imagine a table where:

  • Row a[0]... represents the first set of data or the first array;
  • Row a[1]... is the second set;
  • Row a[2]... is the third.

When an array is nested within another array, it's referred to as a "nested array."

Accessing the elements inside these nested arrays requires using indices along with an additional set of brackets:

c

main.c

Note

Why do we need to specify the data type and size of an array? It helps the compiler understand how much memory should be reserved for your data. Remember: all elements within an array must be of the same type!

To really tap into the power of arrays, upcoming lessons will introduce loops. Loops allow us to automate tasks with arrays, like displaying each element in succession (or based on a certain pattern) or inputting text into arrays. Now, you might wonder, why would we need text in arrays? Stay tuned for the next lesson to find out!

What is the output of this code?

Select the correct answer

Everything was clear?

Section 2. Chapter 5
course content

Course Content

C Basics

Two Dimensional ArraysTwo Dimensional Arrays

Two-dimensional arrays are a bit like tables — think of them as arrays within arrays, with rows and columns.

Declaring a two-dimensional array requires an extra set of square brackets:

Imagine a table where:

  • Row a[0]... represents the first set of data or the first array;
  • Row a[1]... is the second set;
  • Row a[2]... is the third.

When an array is nested within another array, it's referred to as a "nested array."

Accessing the elements inside these nested arrays requires using indices along with an additional set of brackets:

c

main.c

Note

Why do we need to specify the data type and size of an array? It helps the compiler understand how much memory should be reserved for your data. Remember: all elements within an array must be of the same type!

To really tap into the power of arrays, upcoming lessons will introduce loops. Loops allow us to automate tasks with arrays, like displaying each element in succession (or based on a certain pattern) or inputting text into arrays. Now, you might wonder, why would we need text in arrays? Stay tuned for the next lesson to find out!

What is the output of this code?

Select the correct answer

Everything was clear?

Section 2. Chapter 5
some-alt