I am supposed to write a reentrant factorial function, when I searched what a reentrant function is, I found many definitions, such as a reentrant function shouldn't use static or global variable,and the function cannot be changed while in use , I avoided using static or global variables, but I don't know if it is enough for my function be be reentrant or not,
#include <stdio.h>
int fact(int n){
int c,fact = 1;
for (c = 1; c <= n; c++)
fact = fact * c;
return fact;
}
int main()
{
int n;
printf("Enter a number to calculate its factorial\n");
scanf("%d", &n);
fact(n);
printf("Factorial of %d = %d\n", n, fact(n));
return 0;
}