title: TOWER OF HANOI using C
body: <p>I just wrote a program for the Tower of hanoi problem in C using recursion.
  But what stresses is how to manage the complexity of such a problem when the total no. of disks are like 4,5 and whats the logic in the two TOH() recursive calls in the method itself. The program is as follows </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  void TOH(int n,char x,char y,char z);
  
  void main() {
   int n;
   printf("\nEnter number of plates:");
   scanf("%d",&amp;n);
   TOH(n,'A','B','C');
   getch();
  }
  
  void TOH(int n,char x,char y,char z) {
   if(n&gt;0)
   {
    TOH(n-1,x,z,y); // Recursive call 1 
    printf("\n%c -&gt; %c",x,y);
    TOH(n-1,z,y,x); // Recursive call 2
   }
  }
  </code></pre>