This is a program for calculating factorial of a given number without any loop or using recursion. Lets look at the code below.
// Simple Program Factorial Calculation
#include<conio.h>
#include<stdio.h>
int fact(int n)
{
if(n==1||n==0)
return 1;
else
return(fact(n-1)*n);
}
void main()
{
int n,t;
scanf("%d",&n);
printf("%d",fact(n));
getch();
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment