Science, asked by firstg241, 1 month ago

Write a program to find the factorial value of given number​

Answers

Answered by Feirxefett
1

Answer:

C program to find factorial of a number

long factorial(int);

int main() { int n;

printf("Enter a number to calculate its factorial\n"); scanf("%d", &n);

printf("%d! = %ld\n", n, factorial(n));

return 0; }

long factorial(int n) { int c; long r = 1;

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

return r; }

Answered by XxArmyGirlxX
0
  • long factorial(int);
  • int main() { int n;
  • printf("Enter a number to calculate its factorial\n"); scanf("%d", &n);
  • printf("%d! = %ld\n", n, factorial(n));
  • return 0; }
  • long factorial(int n) { int c; long r = 1;
  • for (c = 1; c <= n; c++) r = r * c;
  • return r; }
Similar questions