What's New-Given Below
technicalsymposium
technicalsymposium
technicalsymposium

Lecture Notes-Download


/*TOWER OF HANOI*/
#include<stdio.h>
void tower(int,char,char,char);
void main()
{
int n;
clrscr();
printf("\n\n\t\tTOWER OF HANOI\n\n");
printf("\n\n\tEnter the No. of Disk : ");
scanf("%d",&n);
if(n<1)
printf("\n\tNO DISK TO MOVE\n\n");
else
tower(n,'L','R','C');
getch();
}
void tower(int n,char left,char right,char mid)
{
if(n>0)
{
tower(n-1,left,mid,right);
printf("\nMove disk %d from %c to %c ",n,left,right);
tower(n-1,mid,right,left);
}
}

More Lab Programs with Answers -Given Below-Click and Get Freely

Hosting by Yahoo!

About-Us    Contact-Us    Site-map

©copyright 2009 All rights are reserved to technicalsymposium.com