From the course: C Programming Basics: Flow Control, Variables, and Pointers
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Creating multidimensional arrays - C Tutorial
From the course: C Programming Basics: Flow Control, Variables, and Pointers
Creating multidimensional arrays
- [Instructor] An array is like a line of variables all marching in a row, but not all data prefers a single line. Sometimes you must deal with a grid. In that case, you enter into the realm of the multi-dimensional array. So think of a grid. You have rows and columns. In this code, a two dimensional integer array is declared at line five. Two sets of square brackets are used. One for each dimension in the array. Lines nine through 10 are nested for loops to fill each array element with a value zero. This initializes the array. This step is important because using an array element variable without initializing it can lead to unpredictable results. Say this grid represents a game of tic-tac-toe or knots and crosses. The statement at line 13 sets a value in the middle square. The final set of nested for loops displays the entire grid. Build and run. You see that the one is placed in the lower right corner of the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Manipulating single characters4m 50s
-
(Locked)
Using logical operators4m 8s
-
(Locked)
Manipulating strings5m 29s
-
(Locked)
Challenge: Build a string44s
-
(Locked)
Solution: Build a string2m 15s
-
(Locked)
Exploring constant expressions4m 36s
-
(Locked)
Understanding arrays5m 59s
-
(Locked)
Creating multidimensional arrays4m 10s
-
(Locked)
Challenge: Add a dimension to an array28s
-
(Locked)
Solution: Add a dimension to an array1m 24s
-
(Locked)
Understanding structures5m 54s
-
-
-