Recursion in c language.
Recursion in c language
What is recursion?
When any function call itself it is called recursion and function itself is known as recursive function.
We will discuss one basic program of recursion in c language.It is program of finding factorial of number using recursion.
What is recursion?
When any function call itself it is called recursion and function itself is known as recursive function.
We will discuss one basic program of recursion in c language.It is program of finding factorial of number using recursion.
Recursion in c language
#include<stdio.h>
#include<conio.h>
int fact(int);
void main()
{
clrscr();
clrscr();
int num,x;
printf("Enter number\n");
scanf("%d",&num);
x=fact(num);
printf("%d",x);
getch();
}
int fact(int n)
{
if(n==0)
if(n==0)
return 1;
else
if(n==1)
return 1;
else
return n*fact(n-1);
}
Recursion in c language.
Reviewed by Deepak kumar soni
on
December 31, 2018
Rating:
No comments: