For some reason whenever I input a number above 12 it = 0.
Here is my code (I've tried using a long int but that just comes up with random numbers instead):
#include <stdio.h>
int main()
{
{
int c, n, f = 1;
printf("Enter a number to calculate its factorial\n");
scanf("%d", &n);
for (c = 1; c <= n; c++)
f = f * c;
if (n < 0)
printf("Cannot calculate the factorial of a negative number\n");
else
{
printf("Factorial of %d = %d\n", n, f);
}
}