write a program that finds the factorial of a number using
recursion?
Answer Posted / inderjeet
#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 ? | 62 Yes | 18 No |
Post New Answer View All Answers
How can I list all of the predefined identifiers?
Are local variables initialized to zero by default in c?
What is && in c programming?
Write a program in c to replace any vowel in a string with z?
What is the difference between malloc() and calloc()?
What are the restrictions of a modulus operator?
Can a pointer be null?
Differentiate between static and dynamic modeling.
What are loops c?
How can I avoid the abort, retry, fail messages?
any "C" function by default returns an a) int value b) float value c) char value d) a & b
Do you know pointer in c?
Why pointers are used?
What are runtime error?
All technical questions