Example of recursion in c programming


C programs on recursion. Collections of function recursion programs source code examples in c programming language frequently asked in interview 


Sum of n numbers using recursion in c

35 comments:

  1. The best c site i have ever seen in my life

    ReplyDelete
    Replies
    1. I think so

      Delete
    2. really it is best!!!
      it helps always..

      Delete
  2. ya best site......

    ReplyDelete
  3. Nice site. Very good for beginners....

    ReplyDelete
  4. alka,siya,preema1/6/12, 11:43 AM

    one of the best site.....

    ReplyDelete
  5. loved this site.....thumbs up to the ppl who created this...
    the best site... :)

    ReplyDelete
    Replies
    1. ghanta mera....

      Delete
  6. Replies
    1. haa were are u from???

      Delete
  7. yes this is best c site which contains useful data.

    ReplyDelete
  8. really THE BEST site for c learners............thanks a lot to the one who created this site

    ReplyDelete
  9. whoever created this site looked at every aspect of a problem
    a great site for c learners

    thank u :)

    ReplyDelete
  10. _/\_ for this site and creator...

    ReplyDelete
  11. the best c programming and very flexible answers

    ReplyDelete
  12. write a C program for Tower of Hanoi problem with a example of 4 disks .

    ReplyDelete
  13. best site for ever..............very very helpful for all level programmers ....thank you sir

    ReplyDelete
  14. great site it is....thank u sir...

    ReplyDelete
  15. hello everbody ,
    i am having doubt in tower of hanoi .i tried every site for understanding tower of hanoi
    but none worked.
    following is the program


    #include "stdio.h"

    void towers(int,char,char,char);

    void towers(int n,char frompeg,char topeg,char auxpeg)
    { /* If only 1 disk, make the move and return */
    if(n==1)
    { printf("\nMove disk 1 from peg %c to peg %c",frompeg,topeg);
    return;
    }
    /* Move top n-1 disks from A to B, using C as auxiliary */
    towers(n-1,frompeg,auxpeg,topeg);
    /* Move remaining disks from A to C */
    printf("\nMove disk %d from peg %c to peg %c",n,frompeg,topeg);
    /* Move n-1 disks from B to C using A as auxiliary */
    towers(n-1,auxpeg,topeg,frompeg);
    }
    main()
    { int n;
    printf("Enter the number of disks : ");
    scanf("%d",&n);
    printf("The Tower of Hanoi involves the moves :\n\n");
    towers(n,'A','C','B');
    return 0;
    }

    In the function tower ,there has been 2 recursive function call,does the statement below 1st
    recursive function gets executed if yes then how?
    please explain step wise as i am new to programming.
    Regards

    ReplyDelete
    Replies
    1. #include
      void move(int n,char s,char d)
      {
      printf("Move the %d plate from %c to %c\n",n,s,d);

      }
      void toh(char s,char d,char u,int n)
      {
      if(n!=0)
      {
      toh(s,u,d,n-1);
      move(n,s,d);
      toh(u,d,s,n-1);
      }
      else
      return;

      }
      void main()
      {
      toh('A','B','C',4);

      }

      Delete
  16. ultimate site for c learners !!!!

    ReplyDelete
  17. Thank you... It helped me a lot!!!

    ReplyDelete
  18. Great.. thank you very much

    ReplyDelete
  19. Comment should not be empty

    ReplyDelete
  20. Can anyone tell me about the best site for c++ and data structure as this site is for c????. thankss

    ReplyDelete
  21. really awestruck site i had ever seen for learning c..!! thanks alot.

    ReplyDelete
  22. SUPERB SITE!!!! THANK U SO MUCH.I WAS ABLE TO FIND ALL THE SOLUTIONS FOR ALL C PROGRAMS!!! :-D

    ReplyDelete
  23. hello anyone to sugegst me book with solved exercises in recutions??i be grateful for that help!!thanks

    ReplyDelete
  24. ?
    /and list of best books with solved problems in data structurs using c

    ReplyDelete
  25. very very helpful........thankyou for creating this site
    helped me a lot........._/\_ thank you

    ReplyDelete
    Replies
    1. 1) Write a program with dedicated functions to find the sum of the following series:
      a. 2, 5, 7, . . ., 2N + 1
      b. -2, 4, 46, . . ., 6n3 – 2
      Note that the functions must be written as a recursive functions.
      how to solve this?

      Delete
  26. 2) Write a program to solve the following algebraic formula in a recursive form.

    y = 1 – x + x2/2 – x3/6 + x4/24 + . . . + (-1)nxn/n!

    You may have to write and use a factorial function in this program.
    Note that the factorial function must also be written as a recursive function.

    ReplyDelete