What would you like to do?

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

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!

# Write a C program for simple interest calculation?

int main() { int p,n,count; float r,si; count=1; while(count

# 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 'c' program to calculate the frequencies of different alphabets present in a given string the string of alphabets is to be taken as input from the keyboard?

/* For a short string, like "abaz" a Hashmap like (a:2, b:1, z:1) will be shorter, than a whole alphabet*/ #include #include main() { int count,i,j; char str[50]; printf("E

# Write a c-program calculate lucky number?

include <stdio.h> main() { int a,b; clrscr(); printf("enter a,b values"); scanf("%d%d",&a,&b); a=b%10; printf("\\nlucky number %d",a); getch(); }

# 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

# Program for calculating the factorial of a number using recursion in c?

Quite a popular question, it is the 7th time I answer it;) int fact (int n) {   if (n<=1) return 1; else return n*fact(n-1);   }

# 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

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

# How do you write a program that calculate factorial in javascript?

function factorial(n) { var x=1; while(n>1) x*=(n--); return x; }

# Write a c program to calculate employee payslip?

calculate pay of an employee.

# 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

# 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

# How do you write a c-program to calculate lucky number?

int main (void) { puts ("Your lucky number is 12"); return 0;}