Search This Blog

Showing posts with label Tower of hanoi. Show all posts
Showing posts with label Tower of hanoi. Show all posts

C Program for Animated Solution of Tower of Hanoi Puzzle Problem

This is a c program to solve towers of Hanoi puzzle problem with graphical demonstration. This c program demonstrates solution for tower of Hanoi puzzle with given number of disks. Tower of Hanoi is a mathematical game or puzzle. It is also called tower of Brahma or Lucas' tower. There are three towers (or rods) and a number of disks of different diameters. The program lets you enter the number of disks. As the number of disks increase, the difficulty of puzzle also increase. The disks have hole at center so that it can slide on to the rods. Initially all disks are stacked on the first tower, say tower A, such that no disk is placed over a smaller disk. To win the puzzle you have to move all those disks from tower A (first tower) to tower C (third tower). But there are a few rules to solve the puzzle. They are:

C Program to Solve Tower of Hanoi Puzzle

This is a c program to solve towers of Hanoi puzzle problem. This simple c program give solution for tower of Hanoi problem with any number of disks. Tower of Hanoi is a mathematical game or puzzle. It is also called tower of Brahma or Lucas' tower. There are three towers (or rods) and a number of disks of different diameters. Initially, The disks have hole at center so that it can slide on to the rods. initially all disks are stacked on the first tower, say tower A, such that no disk is placed over a smaller disk. The goal or objective is to move all these disks from tower A (first tower) to tower C (third tower). But you should obey the following rules. The rules of towers of Hanoi puzzle are: