badge

C/C++ program to implement tower of Hanoi Problem Using Recursion

Program in c++ using RECURSION of TOWER OF HANOI

DESCRIPTION:-
WHAT IS TOWER OF HANOI:-I am uploading a pic of this to better understanding of tower of hanoi problem. 

  

OUTPUT OF THE PROGRAM:-




SOURCE CODE:-

 #include<iostream>

#include<conio .h>
using namespace std;
int toh(int n,int beg,int aux,int end)
{
if(n==1)
{
cout<< beg<<"->"<

return 0;
}

toh(n-1,beg,end,aux);
cout<< beg<<"->"<
toh(n-1,aux,beg,end);
}
int main()
{
int n,beg=1,aux=2,end=3;

cout<<"Enter no";
cin>>n;
cout<<"\nSteps for Tower Of Honoi are\n";
toh(n,beg,aux,end);

}




/* IF U FOUND ANY PROBLEM IN THIS PROGRAM  OR IF YOU HAVE ANY QUERY RELATED THIS PROGRAM THEN PLEASE COMMENT IN THIS POST OR YOU CAN DIRECTLY MAIL ME ON piyushkhandelwal029@gmail.com . */

THANKU.
SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments: