Showing posts with label towers of hanoi in c. Show all posts
Showing posts with label towers of hanoi in c. Show all posts

Friday, November 10, 2017

Towers of Hanoi in C

A C program that shows how towers of Hanoi works.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.


Program Listing


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

void move ( int, char, char, char ) ;

void main( )
{
int n = 3 ;

clrscr( ) ;

move ( n, 'A', 'B', 'C' ) ;

getch( ) ;
}

void move ( int n, char sp, char ap, char ep )
{
if ( n == 1 )
printf ("\nMove from %c to %c ", sp, ep ) ;
else
{
move ( n - 1, sp, ep, ap ) ;
move ( 1, sp, ' ', ep ) ;
move ( n - 1, ap, sp, ep ) ;
}
}