Ads 468x60px

Labels

Tuesday, 23 July 2013

Tower Of Hanoi C Code Using Recursion


How to Play:
To play the Towers of Hanoi game, you must move the discs from peg A to peg B by moving one disc at a time.  A larger disc can never sit atop a smaller disc.  Peg C can be used as a holding area.
In the true problem, there are a total of 64 discs.
The number of moves needed to solve the game, based upon the number of discs in the game, can be expressed recursively.
 represents the number of moves based upon the number of discs, n.

Here is the source code of the C program for solving towers of hanoi. The C Program is successfully compiled and run on a Linux system. The program output is also shown below.