1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how this recursive function is working

Discussion in 'C' started by pvicky_20, Nov 7, 2011.

  1. pvicky_20

    pvicky_20 New Member

    Joined:
    Nov 7, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include<stdio.h>
    void fun(int);
    typedef int (*pf) (int, int);
    int proc(pf, int, int);
    
    int main()
    {
        int a=3;
        fun(a);
        return 0;
    }
    void fun(int n)
    {
        if(n > 0)
        {
            fun(--n);
            printf("%d,", n);
            fun(--n);
        }
    }
     
    Last edited by a moderator: Nov 7, 2011
  2. poornaMoksha

    poornaMoksha New Member

    Joined:
    Jan 29, 2011
    Messages:
    150
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Software developer
    Location:
    India
    What are you trying to achieve with this code?
    Please be more precise with your question.
     
  3. archanababu

    archanababu Banned

    Joined:
    Oct 27, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Output of the recursive funtion is 20
    I like C & C++. So i always looking challenges in programming
     

Share This Page