write a program that finds the factorial of a number using
recursion?
Answer Posted / sibnath halder
//*write a c program to calculate factorial by using
recursion*//
#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 ? | 10 Yes | 5 No |
Post New Answer View All Answers
Is it better to bitshift a value than to multiply by 2?
What is the purpose of type declarations?
What is the difference between new and malloc functions?
What is keyword in c?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
What is else if ladder?
What are extern variables in c?
How to create struct variables?
what is the format specifier for printing a pointer value?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
Is there any demerits of using pointer?
What is pass by reference in c?
write an algorithm to display a square matrix.
What are shell structures used for?
What are the loops in c?