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
What is far pointer in c?
Where is volatile variable stored?
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
What is structure pointer in c?
What is the difference between mpi and openmp?
What is the use of define in c?
Why c is called top down?
Is null always defined as 0(zero)?
What’s the special use of UNIONS?
What is indirection?
What is wrong with this initialization?
Difference between malloc() and calloc() function?
Explain what standard functions are available to manipulate strings?
What is pragma c?
What is the use of function in c?