write a program that finds the factorial of a number using
recursion?
Answer Posted / meenakshi
#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 ? | 17 Yes | 8 No |
Post New Answer View All Answers
How can I sort a linked list?
What is the difference between if else and switchstatement
What is the difference between new and malloc functions?
What is difference between structure and union with example?
formula to convert 2500mmh2o into m3/hr
Is this program statement valid? INT = 10.50;
Is flag a keyword in c?
Why static is used in c?
How can I invoke another program or command and trap its output?
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
Is r written in c?
What is %g in c?
how to execute a program using if else condition and the output should enter number and the number is odd only...
Explain how can I make sure that my program is the only one accessing a file?
what is the height of tree if leaf node is at level 3. please explain