Nested Loops and Two-Dimensional Arrays
Earlier you saw how the for loop is a natural tool for processing arrays. Let's go a step further and look at how a for loop within a for loop (nested loops) serves to handle two-dimensional arrays.
First, let's examine what a two-dimensional array is. The arrays used so far are termed one-dimensional arrays because you can visualize each array as a single row of data. You can visualize a two-dimensional array as being more like a table, having both rows and columns of data. You can use a two-dimensional array, for example, to represent quarterly sales figures for six separate districts, with one row of data for each district. Or, you can use a two-dimensional array to represent the position of RoboDork ...
Get The Waite Group's C++ Primer Plus, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.