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


Please Help Members By Posting Answers For Below Questions

Why does notstrcat(string, "!");Work?

643


Why does the call char scanf work?

620


What does the && operator do in a program code?

698


How a string is stored in c?

589


What does & mean in scanf?

604






Give basis knowledge of web designing ...

1574


How can I call fortran?

643


How can you find the day of the week given the date?

617


What does malloc () calloc () realloc () free () do?

560


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.

1727


What is bin sh c?

582


Why & is used in scanf in c?

627


What is the difference between malloc calloc and realloc in c?

649


What is string in c language?

627


Do character constants represent numerical values?

844