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
Can you please compare array with pointer?
What is optimization in c?
Using which language Test cases are added in .ptu file of RTRT unit testing???
Is main is user defined function?
What is null pointer constant?
How will you divide two numbers in a MACRO?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
What is the value of uninitialized variable in c?
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
How can I prevent another program from modifying part of a file that I am modifying?
Is int a keyword in c?
How can I generate floating-point random numbers?
Can you write the algorithm for Queue?
What is hashing in c language?