C program to solve towers of Hanoi problem recursively

Posted: April 28, 2012 in Lab 9
/*C code to solve tower of hanoi recursively
written by- Shivam Rana*/
#include < stdio.h >
int N=3,N1=1,N2=2,N3=3;
void  hanoi (int n, int current, int destination, int medium)
		hanoi(n-1, current, medium, destination);
			printf( "move disk %c from %i to %i\n", (char)(n+'A'-1), current, destination);

		hanoi(n-1, medium, destination, current);

int main (void)
		hanoi(N, N1, N3, N2);
	return 0;

  1. dinesh says:

    very easy steps…….thank u

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s