0% found this document useful (0 votes)
30 views5 pages

Understanding Recursive Functions in C

The document explains the concept of recursion, specifically how a function can call itself, illustrated through a factorial function example. It includes a code snippet demonstrating the implementation of a recursive function to calculate the factorial of a given integer. The document outlines the base case and the recursive case within the function definition.

Uploaded by

Akash Verma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views5 pages

Understanding Recursive Functions in C

The document explains the concept of recursion, specifically how a function can call itself, illustrated through a factorial function example. It includes a code snippet demonstrating the implementation of a recursive function to calculate the factorial of a given integer. The document outlines the base case and the recursive case within the function definition.

Uploaded by

Akash Verma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Recursive Function

Recursion

• When a function calls itself, then the situation is termed as


Function Recursion.
• This can be explained by virtue of following example.

Recursive Function Slide Number 2


Recursion …

int factorial(int);
main()
{
int a;
printf(“enter the integer value whose factorial is to be evaluated”;
scanf(“%d”,a);

Recursive Function Slide Number 3


Recursion …

printf(“The factorial of %d is %d”,a,factorial(a));


getch();
}
int factorial(int x)
{
int fact;

Recursive Function Slide Number 4


Recursion …

if(x==1)
return 1;
else
fact=n*factorial(n-1);
return (fact);
}

Recursive Function Slide Number 5

You might also like