Initialize
Enter number of disks
Step Execution
void main () {
int N;
scanf ( " %d ", &N );
hanoi( 1, 2, 3, N );
}

void hanoi ( int S, int D, int T, int n ) {
if( n == 1 ) {
printf( "Move from tower %d --> %d", S, D );
return ; }
hanoi ( S, T, D, n-1 );
printf( "Move from tower %d --> %d", S, D );
hanoi( T, D, S, n-1 );
return ;
}
Code Output
n :
S :
D :
T :