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
Write a factorial program using C.
What is sizeof int?
How can I swap two values without using a temporary?
Explain data types & how many data types supported by c?
What is oops c?
Explain the Difference between the New and Malloc keyword.
Explain how do you convert strings to numbers in c?
what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above
Explain what is the use of a semicolon (;) at the end of every program statement?
Which control loop is recommended if you have to execute set of statements for fixed number of times?
What are the types of pointers in c?
What are different types of variables in c?
What are linker error?
can anyone please tell about the nested interrupts?
What will the preprocessor do for a program?