PrintNumber ErrorLocation Error Correction DateAdded
8 xxvi remove AP name fixed 2/18/2008
8 46 Looking at Table 3.2, you might notice that the variable types int and short are identical. Why are two different types necessary? The int and short variable types are indeed identical on 32-bit Intel systems (PCs), but they might be different on other types of hardware. For example, on a VAX system, a short and an int aren’t the same size. Instead, a short is 2 bytes, whereas an int is 4 bytes. Remember that C is a flexible, portable language, so it provides different keywords for the two types. If you’re working on a PC, you can use int and short interchangeably. Looking at Table 3.2, you might notice that the variable types int and long are identical. Why are two different types necessary? The int and long variable types are indeed identical on 32-bit Intel systems (PCs), but they might be different on other types of hardware. Remember that C is a flexible, portable language, so it provides different keywords for the two types. If you’re working on a 32-bit PC, you can use int and long interchangeably. 2/18/2008
8 117 You continue calculating recursively until you’re down to a value of 1, in which case you’re finished. The program in Listing 5.5 uses a recursive function to calculate factorials. Because the program uses unsigned integers, it’s limited to an input value of 8; the factorial of 9 and larger values are outside the allowed range for integers. You continue calculating recursively until you’re down to a value of 1, in which case you’re finished. The program in Listing 5.5 uses a recursive function to calculate factorials. Because it is possible to calculate a value that is too large for an integer value, the input value is limited to 8. You can increase this limit to determine what works on your system. 2/18/2008
8 118 Lines 14 through 22 show an interesting if statement. Because a value greater than 8 causes a problem, this if statement checks the value. If it’s greater than 8, an error message is printed; otherwise, the program figures the factorial on line 20 prints the result on line 21. When y ou know there could be a problem, such as a limit on the size of a number, add code to detect the problem and prevent it. Lines 14 through 22 show an interesting if statement. Because a large value can cause a problem, this if statement limits the acceptable value. If it’s greater than 8, an error message is printed; otherwise, the program figures the factorial on line 20 prints the result on line 21. When y ou know there could be a problem, such as a limit on the size of a number, add code to detect the problem and prevent it. 2/18/2008