Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Recursion in C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 27
    Comment on it

    Recursion is the process which repeat itself until some condition is reached otherwise it gets repeated again and again.

     

    In programming languages, if a program allows to call a function inside the same function, then it is called a recursive call of the function.

     

    void recursion() {
       recursion(); /* function calls itself */
    }
    
    int main() {
       recursion();
    }

     

     

     

    Recursion is used in the programming where repetition needs to be done for the same process but for the different values .

     

    Recursion also increase the programming load of the CPU in terms of execution so its better to avoid recursion for large program manipulation.

     

    #include <stdio.h>
    
    int factorial(unsigned int i) {
    
       if(i <= 1) {
          return 1;
       }
       return i * factorial(i - 1);
    }
    
    int  main() {
       int i = 15;
       printf("Factorial of %d is %d\n", i, factorial(i));
       return 0;
    }

     

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: