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: ");

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

return 0;

Thanks for the feedback!

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 for calculating the area of circle in C programming?

  #include #include #include using std::cout; using std::cin; using std::endl; using std::setw(); int main() {   const double PI = 3.14153; double radius

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,

How do you write a program on income tax calculator in C language?

include #include void tax caluclation() { char name[20]; double sal,tax; clrscr(); printf("enter the name of the person:\\n"); scanf("%s",name); printf("ente

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 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

How do you write a program to compute and print the factorial of given number using a while loop in c plus plus?

The problem with factorials is that small numbers have huge  factorials. Even a 64-bit unsigned int is only capable of storing  20 factorial (denoted 20!). Therefore any fac