The Knight’s Tour is a classic chess problem that involves finding a sequence of moves for a knight on a chessboard, such that the knight visits every square exactly once. The knight, a chess piece that moves in an “L”-shape (two squares in one direction and one square perpendicular), must cover the entire chessboard without revisiting any square.

This C++ program is tour of knight on 64 square of chess board.  The goal is to place a knight on an empty chess board and then move the knight to each of the remaining 63 squares while only visiting each square once.  If on visiting the last square the knight is able to hop to the square on which it first started it is known as a closed tour (and so the knight could resume the exact same sequence of moves to complete another tour) while if the knight is unable to hop to the original square, it is known as an open tour.

Output of the C++ Program

Feel free to explore and modify the code to understand how the knight’s tour algorithm works and experiment with different graphics libraries or interfaces for more interactive displays.

This code serves as a starting point for understanding basic graphics programming in C and implementing a solution to a classic chess problem.