//program to get factorial value of a number using recursion
#include <stdio.h>
#include <stdlib.h>
int recur(int n);
int main()
{
int n;
printf("ente a number\n");
scanf("%d",&n);
printf("the factorial value is\n");
printf("%d",recur(n));
getch();
return 0;
}
int recur(int n)
{
if(n<=0)
{
return 1;
}
else
{
return n*recur(n-1);
}
}
#include <stdio.h>
#include <stdlib.h>
int recur(int n);
int main()
{
int n;
printf("ente a number\n");
scanf("%d",&n);
printf("the factorial value is\n");
printf("%d",recur(n));
getch();
return 0;
}
int recur(int n)
{
if(n<=0)
{
return 1;
}
else
{
return n*recur(n-1);
}
}
No comments:
Post a Comment