title: How to index each steps of moving disk in Tower of Hanoi (recursive approach)
body: <p>Printing moving disk from source to destination in TOH( Tower of Hanoi) can easily write in C/C++.(with recursive function)
  But how can we print index each step ?
  C code-</p>
  <pre><code>#include&lt;stdio.h&gt;
  void tower( int disk, int peg1, int peg2, int peg3);// function declaration
  int main()
  {
      int disk;
      int peg1= 1, peg2= 2, peg3= 3;//numbering 
      puts(&quot;enter disk&quot;);
      scanf(&quot;%d&quot;, &amp;disk);//read disks
      tower(disk, peg1, peg2, peg3);//function using
      return 0;
  }
  void tower( int disk, int peg1, int peg2, int peg3)//function definition
  {
      
      if(disk ==1)//if only 1 disk is avialable
      {
      printf(&quot;move disk from peg%d to peg%d\n&quot;,peg1,peg3);//moving disk from source to destination
      }
      else
      {
        tower(disk-1, peg1,peg3,peg2);//moving n-1 disk from peg 1 to peg2 using peg3
        printf(&quot;move disk from peg%d to peg%d\n&quot;, peg1,peg3);//move last biggest disk
        tower(disk-1,peg2,peg1,peg3);//moving n-1 disk from peg2 to peg3 using peg1
      }
  </code></pre>
  <p>It works and prints output.</p>
  <p>But Is there any way to index(1,2,...)each step like-</p>
  <ol>
  <li>move disk from peg1 to peg3</li>
  <li>move disk from peg1 to peg2</li>
  </ol>