This is a classic data structures class programming excercise. This is not that easy. There are many different ways to solve this puzzle. A chess knight moves in L shaped patterns (look it up on wiki). The Knight's Tour excercise is where the knight, starting from somewhere on the board, moves to every space on the board but landing in each space only once.
Many suggest using function recursion, but you'll quickly learn that there is a limit to how many levels deep you can go. This is fine for a typical board but what if I tested on a larger board? What if I don't have a cool OS like linux to let me go deeper? (Windows recursion limit is MUCH lower than in linux last time I tested. ~30,000 vs ~150,000) You can of course do it however you want. My first try uses it and exploits function stack arrays in a stupid way. (but it was short (: )