C examples for Function:Recursive Function
Solve the Problem of the Towers of Hanoi using the method recursion
#include <stdio.h> void move(int N, char chrFrom, char chrTo, char chrTemp); int main()//from w ww .j a v a 2s. c o m { int counter = 5; move(counter, 'L', 'R', 'C'); return(0); } void move(int N, char chrFrom, char chrTo, char chrTemp) { if (N > 0) { move(N-1, chrFrom, chrTemp, chrTo); printf("Move disk %d from %c to %c\n", N, chrFrom, chrTo ); move(N-1, chrTemp, chrTo, chrFrom); } return; }