Question

Fibonaco for its rets ing terms, a) Write a warruse function fibonacci(n) that calculatus 0, 1, 1, 2, 3, 5, 8, 13, 21,... (n)
Untents are Exercises 209 Fig. 5.23 Towers of Hanoi for the case with four disks. b) Move the last disk (the largest) from pe

write in c programming language .

question 5.36
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the answer..

CODE:

#include <stdio.h>

void toh(int n, int from_peg, int to_peg, int temp_peg)
{
   if (n == 1)
   {
       printf("\n %d -> %d", from_peg, to_peg);
       return;
   }
   toh(n-1, from_peg, temp_peg, to_peg);
   printf("\n %d -> %d", from_peg, to_peg);
   toh(n-1, temp_peg, to_peg, from_peg);
}

int main()
{
   int n = 3;
   toh(n, 1, 3, 2);
   return 0;
}

OUTPUT:

toh.c i #include <stdio.h> void toh(int n, int from_peg, int to_peg, int temp_peg) C:\Program Files (x86) Dev-Cpp\ConsolePaus

If you have any doubts please COMMENT..

If you understand the answer please give THUMBS UP...

Add a comment
Know the answer?
Add Answer to:
write in c programming language . question 5.36 Fibonaco for its rets ing terms, a) Write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT