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
Why does notstrcat(string, "!");Work?
Why does the call char scanf work?
What does the && operator do in a program code?
How a string is stored in c?
What does & mean in scanf?
Give basis knowledge of web designing ...
How can I call fortran?
How can you find the day of the week given the date?
What does malloc () calloc () realloc () free () do?
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.
What is bin sh c?
Why & is used in scanf in c?
What is the difference between malloc calloc and realloc in c?
What is string in c language?
Do character constants represent numerical values?