Dividing grids in area?

I want to know the C coding for the following scenario -
Consider An area 100* 100. Squares of side 20 each is taken and whole area is divided into 25 grids .
Now we randomly place some marbles in the whole area. How each marble will find its grid number?
How to do this in C code