C++ Programming Tutorial

 
 
 
 

Image

 # include <iostream.h>
 # include    <conio.h>

 void move(const int n,const int fromTower,
                    const int toTower,const int spareTower)
 {
    if(n>0)
    {
       move((n-1),fromTower,spareTower,toTower);

       cout<<\"\\t Move the Top Disk from Tower-\"<<fromTower
                          <<\" to Tower-\"<<toTower<<\"\\n\";

       move((n-1),spareTower,toTower,fromTower);
    }
 }

 int main( )
 {
    clrscr( );

    cout<<\"\\n\\t **************   TOWERS OF HANOI   **************\\n\"<<endl;
    cout<<\"\\t The Mystery of Towers of Hanoi is as follows : \\n\"<<endl;

    move(4,1,3,2);

    cout<<\"\\n\\t *************************************************\";

    getch( );
    return 0;
 }

    Related Post:
  1. Program to illustrate the implementation of Scaling Transformation along Arbitrary Direction

  2. Program that reads a number and displays it with its digits in reverse order using do-while loop

  3. Program to compute nCr

  4. Implement a Matrix class representing 2-dimensional matrix with the following functionalities i.e. operators + , - , * , == , += &lt;&lt; , &gt;&gt; etc

  5. Program to add two integers of any length

  6. Program that takes input of 2 matrix rows and columns data and displays addition of it using + operator overloading

  7. Program to illustrate the implementation of Stack as an Arithmetic Expression Evaluater

  8. Program to illustrate the declaration , initialization and printing a constant variable

  9. Program that takes short date from a user and displays medium date

  10. Program to illustrate static member functions

  11. Program to estimate value of First Derivative of the function at the given points from the given data using Backward Difference Formula , Forward diff

  12. Program that reads a number ,coumputes and displays its factorial ( using for loop )

  13. Program to convert an Infix Expression into a Postfix Expression

  14. Program to illustrate the Radix Sort

  15. Program that reads a number and prints even if the number is even and prints odd if the number is odd.

  16. Program to create a circular linked list

  17. Program to reverse the content of an integer array

  18. Program that performs SCANNING of the following program and finds the entire float,integer variables and keywords present in the program

  19. Program to illustrate the use of operator * and &

  20. Program to convert an Infix Expression into a Postfix Expression using Linked List as a Stack

 
 
Didn't find what you were looking for? Find more on Program to solve the Towers of Hanoi Problem (using Recursive Algorithm)