What would you like to do?

How do you write a C program to calculate the factorial of given no?

already exists.

Would you like to merge this question into it?

already exists as an alternate of this question.

Would you like to make it the primary and merge this question into it?

exists and is an alternate of .

// Iterative solution
unsigned long iterativeFactorial(const unsigned long n) {

unsigned long i, factorial = 1;
for(i = 1; i <= n; i++) {
factorial *= i;
}

return factorial;

}

// Recursive solution
unsigned long recursiveFactorial(const unsigned long n) {

if(n <= 1) {
return n;
}

return n * recursiveFactorial(n - 1);

}

// Sample calls
int main() {

unsigned long n;
printf("Enter a number to find its factorial: ");
scanf("%u",&n);

printf("Iterative factorial: %u\n", iterativeFactorial(n));
printf("Recursive factorial: %u\n", recursiveFactorial(n));

return 0;

}
Thanks for the feedback!

C program to calculate factorial of 100 using array?

hi friend hope u got the ans: int main() { int count=1,n,fact=1; printf("Enter the value which u need for factorial"); scanf("%d",&n); while(count=0;i--){ printf("%d",fac

Write a program in c to calculate age?

//program to find the age of given date of birth //program to find the age of given date of birth #include #include int main(void) { struct date d; int bd,bm,b

C program to calculate first symbol of given grammar?

include"stdio.h" #include #define max 10 #define MAX 15 char array[max][MAX],temp[max][MAX]; int c,n,t;void fun(int,int[]); int fun2(int i,int j,int p[],int key)

Write a C program to find the factorial of a given number?

This program will compute N Factorial for any N, and does not suffer from overflow, because it uses a bin technique and handles each digit individually. For large values of N,

Write a c program to print factorial?

/*program for finding the factorial*/ void main() { int a,b=1; clrscr(); printf("Please enter any number to find its factorial\\n"); scanf("%d",&a); while(a>1)

How do you write a program to find the factorial of a given number using the recursion or non-recursion?

The following program will find the factorial of any number using both recursion and non-recursion, using different precisions typically available, in this case to the Microso

Write a program in c plus plus to compute the factorial of a given number?

The factorial of a real number, n, is the product of all positive real numbers less than or equal to n, denoted as n!. Thus, 5! = 5*4*3*2*1 = 120. Computing factorials is a n