Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program of hanoi tower

Posted By: Blasa Fischer     Category: C Programming     Views: 5374

Write a program of hanoi tower.

Code for Program of hanoi tower in C Programming

#include<stdio.h>
#include<conio.h>

void main()
{
  int n;
  int hanoi(int,char,char,char);
  clrscr();
  printf("Enter  the no of disk:");
  scanf("%d",&n);
  hanoi(n,'a','b','c');
  getch();
}
int hanoi(int n,char a, char b, char c)
{
while(n!=0)
{
hanoi(n-1,a,c,b);
printf("Moving disk %d from %c tower to %c tower\n",n,a,c);
hanoi(n-1,b,a,c);
break;
}
return 0;

}
  
Share: 


Didn't find what you were looking for? Find more on Program of hanoi tower Or get search suggestion and latest updates.

Blasa Fischer
Blasa Fischer author of Program of hanoi tower is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!