this code is to find the factorial of a number by the recursion principle.
trace the control flow in this program very carefully.
finding factorial of a number.
#include<stdio.h>
main()
{
unsigned long int n,f;
printf("\nenter the number for which you want to find the factorial");
scanf("%d",&n);
f=fact(n);
printf("\nthe factorial of the number %d is %d",n,f);
}
fact(int n)
{
int k;
if(n==0)
return(1);
else
{
k=n*fact(n-1);
}
return(k);
}
bumsfeld
413
Nearly a Posting Virtuoso
JLChafardet
0
Newbie Poster
JLChafardet
0
Newbie Poster
JLChafardet
0
Newbie Poster
megha.s
0
Newbie Poster
Adak
419
Nearly a Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.