Recursive function call : Function Recursive « Function « C / ANSI-C






Recursive function call

  
#include <stdio.h>

int add(int pk,int pm);

main() {
    
   int k = 2;
   int i;
   int m = 3;

   i = add(k,m);

   printf("i =  %d\n",i);
}

int add(int addk,int addm) {
    if(addm==0) 
        return(addk); 
    else 
        return(1+add(addk,addm-1));
}

           
       








Related examples in the same category

1.A recursive power functionA recursive power function
2.Calculating factorials using recursion
3.Prints out Fibonacci numbersPrints out Fibonacci numbers
4.Function: Recursive call
5.Copy string using recursion
6.Recursive function with static variable