write a program that finds the factorial of a number using
recursion?

Answer Posted / inderjeet

#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 ?    62 Yes 18 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I list all of the predefined identifiers?

585


Are local variables initialized to zero by default in c?

557


What is && in c programming?

685


Write a program in c to replace any vowel in a string with z?

701


What is the difference between malloc() and calloc()?

621






What are the restrictions of a modulus operator?

642


Can a pointer be null?

569


Differentiate between static and dynamic modeling.

626


What are loops c?

627


How can I avoid the abort, retry, fail messages?

667


any "C" function by default returns an a) int value b) float value c) char value d) a & b

673


Do you know pointer in c?

595


Why pointers are used?

635


What are runtime error?

636


All technical questions

1518