It gives you a 10 x 10 matrix. You can see it better if you replaces in line 6
with another char, like -
.
If you want a better explanation for the code we can begin with the loops. The y
is the row index and the x
the column index, so that, in the first iteration, you are on (0,0), so you are in the first position.
In the next step, you will be in the (0,1), then (0,2) and so, until you arrives to (0,size
). In this case, next step will be (1,0), and repeat again the process. This means that you change from the row 0 to row 1.
In this point you know how to move along the table. So, you only have to learn to decide if you have to put a " " or a "#". This is why the module operator is used(%
).
You can have a look on Google about how %
works. For your example, it is enough knowing that number % 2
will be always 0 or 1 depending on if the number is even or odd.
Suming up, this code is checking for each one of the cells in the table if they are even or odd, and puting a #
or a
depending on the case.