Recursive C Program:
Aim:To print the factorial of Number.
Program:
#include<stdio.h>
int fact(int n)
void main()
{
int num,f;
Printf("Enter a Number:");
scant("%d",&num);
f=fact(num);
printf("\nfactorial of Number %d is %d",num,f);
}
int fact(int n)
{
if(n==0)
return (1);
else
return (n*fact(n-1));
}
Output:
Enter a Number: 4
Factorial of 4 is 24
Click Here to know other Programs
I think there is a mistake in this program
ReplyDeletePositive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. c program for lcm of two numbers
ReplyDelete