Tower of Hanoi – C Program
Tower of Hanoi C Program
It is basically a mathematical puzzle game.
Suppose there are 3 sticks A,B & C and suppose on stick A, there are finite number (n) of disks with decreasing size, the objective of the game is to move the disk from stick A to stick C using stick B as auxiliary obeying some rules.
Rules of the game are as follows:
Rule 1: Only 1 disk can be moved at at time, specifically only the top disk on any stick may moved to any other stick.
Rule 2: At no time can a larger disk can be placed on a smaller disk.
Sometimes we will write X->Y to denote the instruction move the top disk from stick X to stick Y where X & Y may be any of the three sticks.
Program of Tower of Hanoi:
printf("\nenter the number of disk");
In the above program, A, B & C are three sticks.