Virtual 1D index for 2D coordinates

Understanding Virtual 1D index &#x2192; 2D coordinates: How does this formula work? row = index / n col = index % n Mapping 1D to 2D Imagine you have a bookshelf with 4 shelves (rows), and each shelf holds 3 books (columns). Shelf 0: [Book0] [Book1] [Book2] Shelf 1: [Book3] [Book4] [Book5] Shelf 2: