SA Activities
a CSE.B-Tech Student's Blog
Sunday, 20 October 2013
C-Program to Factorial of a Number Using Function
#include<stdio.h>
int factorial(int);
main ()
{
int f,n;
printf("Enter the Number\t");
scanf("%d",&n);
f=factorial(n);
printf("Factorial of %d is \t%d",n,f);
}
int factorial(int n)
{
int i,fact=1;
for(i=n;i>0;i--)
{
fact=fact*i;
}
return;
}
output
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment