I'm writing a program that's supposed to compute and print the factorials of the numbers 1-10, but when I compile and run it, it displays 0 where the factorial of ten should be. I messed with my loops and changed it so it did 1-11, and it printed zero for both numbers over one digit. I'm using %lu in the print statement instead of %d, and I have no idea what's causing this problem!
here's the code:
Code:
#include <stdio.h>
#include "simpio.h"
#include "genlib.h"
main()
{
int original, factorial, i;
original=1;
factorial=1;
i=1;
for (original>=1; original<=10; original++)
{
for (i=1; i<=original; i++)
{
factorial=factorial*i
}
printf ("%d %lu\n", original, factorial);
}
getchar();
}
thanks in advance!