From the course: C Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Work the grid

Solution: Work the grid - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Solution: Work the grid

(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…

Contents