write a program that finds the factorial of a number using
recursion?
Answer Posted / bhargav
#include<stdio.h>
void main()
{
int factorial(int);
int n;
printf("Enter a number: ");
scanf("%d",&n);
printf("Factorial of %d is: %d",n,factorial(n));
}
int factorial(int f)
{
int fact;
if(f==1)
return(1);
else
fact=f*factorial(f-1);
return(fact);
}
| Is This Answer Correct ? | 13 Yes | 4 No |
Post New Answer View All Answers
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
why return type of main is not necessary in linux
What are bitwise shift operators in c programming?
Can we use visual studio for c?
Explain why can’t constant values be used to define an array’s initial size?
How can I call fortran?
What is #line?
Why do we use header files in c?
What does %d do?
What is an array? What the different types of arrays in c?
Why is c faster?
Why we use int main and void main?
What the different types of arrays in c?
What is the use of bitwise operator?
What is the most efficient way to count the number of bits which are set in an integer?