Coming Soon

This video is not yet available

#18 Applications of Stack #1 Tower of Hanoi

Video 18 of 302023-12-08
Course Progress60%

Code & Notes

Applications of Stack

Source Code

// Tower of Hanoi

#include <stdio.h>
void towerOfHanoi(int n, int start, int stop, int temp)
{
    if (n > 0)
    {
        towerOfHanoi(n - 1, start, temp, stop);
        printf("Move Disk %d from Tower %d -> %d\n", n, start, stop);
        towerOfHanoi(n - 1, temp, stop, start);
    }
}
int main()
{
    int n;
    printf("Enter the number of Disks: ");
    scanf("%d", &n);
    towerOfHanoi(n, 1, 3, 2);
    return 0;
}

Time Complexity

Playlist

Top 30 C Programming Assignment For Learners

30 videos