RECURSION

Recursion in programming refers to the ability of a function to call itself. In C, recursive functions are functions that include calls to themselves, either directly or indirectly. Recursion is particularly useful for solving problems that can be broken down into smaller, similar subproblems.

#include<stdio.h>

int getsum(int);

int main()

{

  int a=5,b;

  int sum;

  sum=getsum(a);

  printf(“%d/n”, sum);

  return 0;

}

int getsum(int a)

{

  int b=a;

  if(a>1){

  a--;

  return b+getsum(a);

}

  else

{

  return 1;

}

}

output 15

recursion is a processing concept where a function call itself repeatatly until a certain condition is met . it allows solving complex problem by breaking them down into smaller sub problems.

Recursion can be a powerful technique for solving problems that have a recursion structure.

factorial of a value

#include<stdio.h>

int factorial(int);

void main()

{

  int num=5;

  int result = factorial(num);

  printf(“the factorial of %d is %d/n”, num, result);

} 

int factorial(int a)

{

  if(a==0 || a==1)

{

  return 0;

}

  else

{

  return a+=*factorial(a-1);

}

}