write a program that finds the factorial of a number using
recursion?
Answer Posted / anandi
#include<stdio.h>
#include<conio.h>
void main()
{
int factorial(int);
int n;
clrscr();
printf("Enter a number: ");
scanf("%d",&n);
printf("Factorial of %d is: %d",n,factorial(n));
getch();
}
int factorial(int f)
{
int fact;
if(f==1)
return(1);
else
fact=f*factorial(f-1);
return(fact);
}
| Is This Answer Correct ? | 197 Yes | 32 No |
Post New Answer View All Answers
Why malloc is faster than calloc?
Tell us the use of fflush() function in c language?
Subtract Two Number Without Using Subtraction Operator
What is modeling?
What is a pointer value and address in c?
What are the different types of pointers used in c language?
How can I pad a string to a known length?
if p is a string contained in a string?
Do you know the difference between exit() and _exit() function in c?
Why is c called c not d or e?
What does int main () mean?
Why clrscr is used in c?
find the sum of two matrices and WAP for it.
What is the use of #include in c?
Explain what is the benefit of using an enum rather than a #define constant?