From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Working with multi-dimensional arrays - C Tutorial
From the course: Complete Guide to C Programming Foundations
Working with multi-dimensional arrays
- [Instructor] Most arrays are linear or one dimensional, but they can branch out into other dimensions as well. For example, in this code, you see a two-dimensional array. It works like a table with rows and columns. The grid array declaration can be read as a matrix of five rows of two columns, or five columns of two rows. The arrays elements must also be referenced by using the same dimensions. At lines 10 and 11, you see the two sets of brackets that refer to element X and elements zero and one. The same bracket pairs are used in line 15 as well. Run to see the table, and there it is. The multidimensional array in this code generates a three by three matrix. The character array tictactoe is two dimensional with three elements in each dimension, or three rows of three columns, essentially a grid or matrix. Nested loops fill the grid with period characters. A second set of nested loops outputs the grid. See how the elements are referenced at line 18? Variables x and y represent…
Contents
-
-
-
-
-
-
-
-
Understanding arrays2m 48s
-
(Locked)
Working with arrays2m 51s
-
(Locked)
Challenge: Creating an array55s
-
(Locked)
Solution: Creating an array1m 41s
-
(Locked)
Passing an array to a function2m 45s
-
(Locked)
Working with multi-dimensional arrays2m 42s
-
(Locked)
Building a structure3m 31s
-
(Locked)
Nesting structures3m 17s
-
(Locked)
Challenge: Constructing a structure1m 3s
-
(Locked)
Solution: Constructing a structure3m 5s
-
(Locked)
Putting structures into an array2m 37s
-
(Locked)
Working with structures and functions3m 47s
-
(Locked)
Chapter challenge: Manipulating a structure1m 22s
-
(Locked)
Chapter solution: Manipulating a structure2m 4s
-
-
-
-
-
-