Members BookmarksPolls Fresher Jobs Funny Pictures MCA Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

Advertisements


website counter



C Program-Tower of Hanoi


Posted Date: 04 Nov 2007    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology

Posted By: Arun Jadhav       Member Level: Diamond
Rating:     Points: 5



In this program number of disks(entered by user) are transfered from left right using recursion following condition that smaller disk always comes over the bigger disk.

#include
#include

void tower_of_hanoi(int n, char LEFT, char RIGHT, char CENTER)
{
if(n>0)
{
tower_of_hanoi(n-1, LEFT, CENTER, RIGHT);
printf("\n\tMove disk %d from %c to %c", n, LEFT, RIGHT);
tower_of_hanoi(n-1, CENTER, RIGHT, LEFT);
}
}

void main()
{
int n;
printf("\nEnter no. of disks: ");
scanf("%d",&n);
clrscr();
printf("\nSOLUTION \n\t (L=Left,R=Right,C=Ceter)\n");
tower_of_hanoi(n,'L','R','C');
}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: More Keywords Shortcuts
Previous Resource: C Program: Login
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources


Contact Us    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.