Write a cpp program to print tower of hanoi?

#include<iostream.h>
#include<conio.h>
void toh(int n, char a, char b, char c)
{
 if(n>=1)
  {
    toh(n-1,a,c,b);
    cout<<a<<" to "<<c<<endl;
    toh(n-1,b,a,c);
  }
}
void main()
{
 clrscr();
 char A,B,C;
 toh(3,'A','B','C');
 getch();
}

Ourput:


Comments

Popular posts from this blog

Larch Soft Pvt. Ltd. - Best Website & Hosting Provider