The instructor demonstrates a solution for the matrix problem, explaining why one approach is best for solving the challenge. An alternative approach is demonstrated along with an explanation of its weaknesses.
(upbeat music) … - [Instructor] This chapter's course challenge included … a lot of individual parts. … So I hope you got them all in, … and the output is good. Here is my solution, … where you see the nested loops down here starting … at line 20. … Rows are processed in the outer loop. … The first inside loop generates the separator row. … The second inside loop outputs the values. … This loop uses the variable column to count column … characters from A through J. … These are new variables added to the code. … Variable sc counts the number letter rows. … I'm sure this task can be done in other ways. … But I used a separate variable C, which is initialized … back on line 18, zero for the first row. … So variable sc tracks the number rows, … the letter number combinations, … and variable row is the total overall rows. … The way to determine which inner loop to execute is done … by a mod calculation or expression here at line 24. … So this determines whether the output is odd or even … and for odd rows, we have a separator …
- Writing your first C program
- Working the C development cycle
- Adding comments to code for clarity
- C language data types
- Declaring variables
- Making new data types
- Typecasting variables
- Using math, assignment, and logical operators
- Creating for and while loops
- Nesting loops
- Creating functions
- Returning values from functions
- Passing arguments to functions
- Creating recursive functions
Skill Level Intermediate
C: Data Structures, Pointers, and File Systemswith Dan Gookin2h 57m Intermediate
1. The Fundamentals of C
2. Variables and Values
3. Operators and Math
4. Decisions and Loops
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.