Answer:

Nothing. With the braces in place, the else is followed by a block, which in this case contains just one statement. With the braces removed, the else is followed by a single statement.

Both of these follow correct syntax and at run time both will have the same effect. Sometimes programmers use a block even when one is not needed to add clarity.

Live Factorial Calculator

Here is a Javascript version of the factorial calculator:



Enter N:

Try some values for N that test the boundaries: -1, 0, 1. Then try some small values like 6 or 12.

Try a value of 25. Something surprising happens. The the result is very, very large! It is so large that it is expressed in scientific notation. JavaScript (in which this program is written) automatically does this. Java does not do this, so there is an important difference in how this program behaves and how the Java program behaves. If you need the values of large factorials, use a double precision variable for fact. This is not completely satisfactory, however, because it is not completely accurate (double precision floating point values have only about 15 decimal digits of accuracy).

QUESTION 12:

If you drop a brick from a tower, what happens?