These are 10 of the most common for loop algorithms used when working with two-dimensional arrays, also known as matrices. Each algorithm uses nested for loops to visit every value in a grid of data.