Tower of Hanoi | Lab 1 | Logic and Program

 

Tower of Hanoi

Watch this video in 1.5x if you want, coz the video is litter longer and I hope it will be useful. The program uses the concept of recursion and understanding it completely is obviously little tough, and I tried to complete it as best as I can and I hope you will find it useful. Try to visualize the concept and learn.

Kindly comment down the pros and cons of the video. So that will improve myself.

Tower of Hanoi <- Video Link!!!


Source Code:


// 1 Tower of Hanoi

#include <stdio.h>

int towerofHanoi(int,char,char,char);


void main() {

       int n;

       printf("Enter the number of disks \n");

       scanf("%d",&n);

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

}


int towerofHanoi(int n,char src, char dest, char aux) {

       if (n==1) {

        printf("Move disk 1 from %c to %c \n",src,dest);

       }

       else {

        towerofHanoi(n-1,src,aux,dest);

        printf("Move disk %d from %c to %c\n",n,src,dest);

        towerofHanoi(n-1,aux,dest,src);

       }

}


Don't forget to like, share, and subscribe for more informative and engaging videos on programming and computer science in Tamil.

Welcome to the official YouTube channel of Rahul Babu M P, a college student with a passion for technology and innovation! On this channel, you'll find a variety of content focused on exploring the latest trends in tech, from product reviews and unboxings to tutorials and demonstrations.

But that's not all! Rahul's channel is also a hub for discussions and insights on a range of fascinating topics, including gaming, artificial intelligence, and cutting-edge software. Whether you're a tech enthusiast or simply looking to stay up-to-date on the latest advancements in the industry, you're sure to find something of interest here.

So hit that subscribe button and join the conversation! You never know what new insights and discoveries await you on Rahul Babu M P's YouTube channel.



Comments

Popular posts from this blog

Queue Data Structure Implementation using Arrays | Lab 3 | Logic and Program | Tamil | MPR

Andrax - Advanced pentesting Platform...