From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,600 courses taught by industry experts.

Chapter challenge: Sorting a grid

Chapter challenge: Sorting a grid - C Tutorial

From the course: Complete Guide to C Programming Foundations

Chapter challenge: Sorting a grid

(bright music) - Here you see the quite brief code skeleton for this chapter's challenge. It offers some hints as to what you can do. See the randomizer, because the code uses and generates random numbers. Storage is allocated for a grid, which has a number of rows and columns. The grid is populated with random values in the range of zero through 99. The grid is sorted using a quick sort. I've already presented the compare function in the code, and lastly, you output the grid. Here's a test run of my solution. You see a five by five grid of random values in the range of zero through 99 sorted, but you also see that the grid is output by columns and not rows. The sorted numbers appear lowest in the first column, then rising through the second, third, fourth, and finally the fifth column containing the highest values. This is the output your solution must match. Here are some big picture details. Allocate storage for a grid of in integers. Populate the grid with random values in the…

Contents