Computer Science, asked by sindhu43, 1 year ago

write a problem to find a fatorial value in c program

Answers

Answered by Anonymous
0

Factorial program in C programming language: C program to find and print factorial of a number, three methods are given, the first one uses for loop, the second uses a function to find factorial and the third uses recursion. Factorial is represented using '!', so five factorial will be written as (5!), n factorial as (n!). Also, n! = n*(n-1)*(n-2)*(n-3)...3.2.1 and zero factorial is defined as one i.e. 0! = 1.

Answered by Anonymous
0

___________________________________________________

#include <stdio.h>

int main()

{

int c, n, fact = 1;

printf("Enter a number to calculate its factorial\n");

scanf("%d", &n);

for (c = 1; c <= n; c++)

fact = fact * c;

printf("Factorial of %d = %d\n", n, fact);

return 0;

}

hope it help u

Similar questions