Take a look at this loop:
for( i = length; i <= 20; length += updateLength)
{
double period = pendulum_Period(length);
printf("%.6f\t\t\t%.6f\n", length, period);
printf("------------------------------------------\n");
}
Now what happens if you change the first printf to
printf("loop %d: %.6f\t\t\t%.6f\n", i, length, period);
That should help you figure out why the loop continues infinitely.