Menu
Home
Contact Us
Home
Contact Us
Write a C Program to Implement Towers of Hanoi
Sumit Kar
September 06, 2014
#include <stdio.h>
void toh(int,char,char,char);
void main()
{
int n=3;
toh(n,'A','B','C');
}
void toh(int n,char a,char b,char c)
{
if(n==1)
printf("\nMoved from %c to %c",a,c);
else
{
toh(n-1,a,c,b);
toh(1,a,' ',c);
toh(n-1,b,a,c);
}
}
0 Comments
Pageviews
Search This Blog
Popular Posts
Loops and Conditional Statements
June 29, 2023
Strings
July 02, 2023
Programming Languages
June 29, 2023
Functions and Methods
June 29, 2023
Variables, Data Types and Operators
June 29, 2023
Labels
C - Programming
Java Programming
Basic
Technology
8085
Assembly Programming
For Loop
Numerical Methods
WhatsApp
Algorithm
Shell Programming
Programming
Networking
Windows
Android
C++ Programming
CPP
Introduction to Programming
If Else
Tricky
Internet
Microsoft
Pattern
Photography
Socket Program
News
While Loop
Array
DBMS
DS
Macro
Recursion
User Defined Function
Conditional Operator
Data Structure
Durga Puja
Earthquake
Google
Mela
Nokia
SQL
Share
Yahoo
Airtel
Bio
Command Prompt
Confused
Facebook
Finance
Firefox
Ganges
Graph
HokKolorob
Input
Kolkata
MCQ
Math
Matrix
NetNeutrality
Oracle
Religion
Search
Sumit Kar
Survey
Switch Case
Viral
Virus
Visual Studio
developerslab101
do-while
featured
featured_slider
generativeAi
July 2023
2
June 2023
6
April 2022
3
May 2020
1
October 2015
4
September 2015
3
August 2015
3
July 2015
9
June 2015
9
May 2015
20
April 2015
7
March 2015
22
February 2015
7
January 2015
8
November 2014
70
October 2014
6
September 2014
82
Report Abuse
Contact form
0 Comments