Errata for Corrections and Clarifications

To report errors or make suggestions, please email author.

Errors to be corrected in a future printing

Contents
  1. Page viii, line 6.
    "`13.6 Making It Work" should be "13.6 Making It Work".
Preface
  1. Page xii, line 8 from the bottom.
    "four" should be "of".
  2. Page xii, lines 6 and 7 from the bottom.
    "long long, which are used" should be "long long are used".
  3. Page xiii, last line.
    Add " For clarity of the presentation, programs are displayed with the light blue background. interactive executions of programs, functions, statements, and expressions are displayed with the dark blue background. The output from programs are displayed with the grey background. Practical application examples are separated from the main text by two thick horizontal blue lines, one at the beginning and the other at the end."
  4. Page xv, line 9 from the bottom.
    "quizes" should be "quizzes".
Chapter 2
  1. Page 15, line 15.
    "the header stdio.h" should be "the file stdio.h"
  2. Page 20, line 20 from the bottom.
    "Exit code: -1" should be ">Exit code: -1".
  3. Page 21, last line and page 22, first line.
    "sections 3.16.3 and 6.13.3." should be "section 3.16.3 in Chapter 3 and section 6.13.3 in Chapter 6."
  4. Page 26, line 12 from the bottom.
    "C:/Documents and Setting/Administrator," should be "C:/Documents and Setting/Administrator/eme5".
  5. Page 38, line 14.
    "37.818550 meters" should be "37.818550 kilometers"
Chapter 3
  1. Page 50, line 1 from the bottom.
    "signed char" should be "signed int".
  2. Page 51, line 4.
    "fewer" should be "with".
  3. Page 57, line 17.
    "Arrays in C can be declared and its elements can be accessed by operand []."
    should be
    "Arrays in C can be declared and its elements can be accessed by operand []. Details about arrays will be described in Chapter 10."
  4. Page 73, line 7 from the bottom.
    "Pipeline" should be "The pipeline".
  5. Page 74, line 9 from the bottom.
    > tar -xvfz program.tgz program
    should be
    > tar -cvfz program.tgz program
  6. Page 81, Exercise 17.
    "in signed representation." should be "in signed representation?".
  7. Page 81, Exercise 17.
    "in unsigned representation:" should be "in unsigned representation?".
Chapter 4
  1. Page 110, line 18.
    "for-loop" should be "for loop".
Chapter 5
  1. Page 129, lines 2 and 3.
     The program enters a grade in one of alphabetic letters A, B,
     C, D, F, it prints the corresponding score the numerical value.
     The program uses a swith-statement */
       
    should be
     The program accepts a grade in one of alphabetic letters A, B, C, D, 
     and F. It then prints the corresponding score in the numerical value.
     The program uses a switch-statement */
       
  2. Page 133, line 3 from the bottom.
    "Program 5.7" should be "Program 5.6".
  3. Page 143, line 3 from the bottom.
    "a mathematical the function" should be "a mathematical function".
Chapter 6
  1. Page 200, line 13 from the bottom.
    "The plot generated by Programs 6.13." should be "The plot generated by Programs 6.13 and 10.21."
  2. Page 215, line 18.
    "Options" should be "View"
  3. Page 224, line 8 (Found by Weimin Ge).
    the denominator "(2i+1)" should be "(2i+1)M_PI", where M_PI should be the math symbol for pi.
  4. Page 225, line 9 (Found by Wai Hong Tsang).
    "know as" should be "known as".
  5. Page 226, line 19.
    x(t) = 4.2e^(-1.57t) - 0.2e^(-54.2t)
    should be
    x(t) = 4.12e^(-1.57t) - 0.12e^(-54.2t)
  6. Page 226, line 23.
    x(t) = 4(1-3t)e^(-3t)
    should be
    x(t) = 4(1+6t)e^(-6t)
  7. Page 226, line 28.
    x(t) = 4e^(-0.5t)sin(3t+2)
    should be
    x(t) = 4.06e^(-0.5t)sin(3t+1.4)
Chapter 7
  1. Page 231, line 19.
    "a maco parameter" should be "a macro parameter".
  2. Page 235, line 9.
    "An example of using the macro _WIN32 is given in the next section" should be "An example of using the macro _WIN32 is given in section 7.4"
  3. Page 242, line 12.
    "whent ≥ 0" should be "when t ≥ 0".
  4. Page 246, Exercise 11 (Found by Wai Hong Tsang).
    "for discs of radius 1 to 10 meters" should be "for discs of radii from 1 to 10 meters".
  5. Page 246, Exercise 12 (Found by Wai Hong Tsang).
    "for spheres with radiuses ranging from 1 to 10 meters" should be "for spheres with radii ranging from 1 to 10 meters".
Chapter 8
  1. Page 264, line 7.
    "externprog.exe" should be "accelprog.exe".
  2. Page 264, line 15.
    "accelexter.exe" should be "accelextern.exe".
Chapter 14
  1. Page 276, line 5 from the bottom.
    "# of characters:"
    should be
    "# of printed characters:"
Chapter 10
  1. Page 303, line 9
    "the bubble sort" should be "the selection sort". All "bubble sort" throughout the book should be changed to "selection sort", which is more efficient for sorting data in a linked list. The pseudocode (sortbubble.p) and source code (sortbubble.c) for the bubble sort are available in the updated source code for the book from here. The updated PPT for both selection sort and bubble sort for the book is available from the publisher.
  2. Page 303, lines 9-14
    "As the algorithm is processed, the smaller values will gradually propagate toward the top of the array like air bubbles rising in the water, whereas the larger values will sink to the bottom of the array. The algorithm processes the array through several iterations. After the first iteration, the smallest number will be sorted out and placed at the top of the array. After the second iteration, the second smallest number will be sorted out and placed at the second element of the array. At each iteration, the largest number in the remaining elements of the array will be sorted out."
    should be changed to
    "The algorithm processes the array through several iterations. After the first iteration, the smallest number will be selected and placed at the top of the array. After the second iteration, the second smallest number will be selected and placed at the second element of the array. At each iteration, the smallest number in the remaining elements of the array will be selected."
  3. Page 303, Program 10.4 of the original pseudocode for the selection sort could be changed to the code below with a more efficient algorithm, which needs only one swap in an iteration. // File: sort.p // Pseudocode for the selection sort with one swap in an iteration declare array a[N] with index from 0 to N-1 // find the smallest value in the remaining part of // the array in each iteration starting with a[i] for i = 0, 1, ..., N-1 imin = i; // assume the first element is the minimum // compare a[imin] with a[j] for j from i+1 to N-1 for j = i+1, ..., N-1 if(a[imin] > a[j]) // if a[j] is smaller, it is the new minimum imin = j // remember its index endif endfor if(imin != i) // swap the values of a[i] and a[imin] temp = a[i] a[i] = a[imin] a[imin] = temp endif endfor
  4. Page 305, Program 10.5 of the original source code for the selection sort could be changed to the code below with a more efficient algorithm, which needs only one swap in an iteration. /* File: sort.c Sort an array using the selection sort with one swap in an iteration */ #include <stdio.h> #define N 8 /* number of elements for array a */ int main() { /* declare array a with initialization */ double a[N] = {3.0, 21.0, 0.0, -3.0, 34.0, -14.0, 45.0, 18.0}; double temp; /* temporary for swap */ int i, j, imin; /* variables for array index */ printf("The original data:\n"); for(i = 0; i < N; i++) { /* print the original array */ printf("%g ", a[i]); } printf("\nThe sorted data in each iteration:\n"); /* find the smallest value in the remaining part of the array in each iteration starting with a[i] */ for(i = 0; i < N-1; i++) { imin = i; /* assume the first element is the minimum */ /* compare a[imin] with a[j] for j from i+1 to N-1 */ for(j = i+1; j < N; j++) { if(a[imin] > a[j]) { /* if a[j] is smaller, it is the new min */ imin = j; /* remember its index */ } } if(imin != i) { /* swap the values of a[i] and a[imin] */ temp = a[i]; a[i] = a[imin]; a[imin] = temp; } for(j = 0; j < N; j++) { /* print the array in each iteration */ printf("%g ", a[j]); } printf("\n"); } return 0; }
  5. Page 309, line 9 from the bottom.
    "the switch statement" should be "the switch statement"
  6. Page 310, line 17.
    /* face in each roll*/
    should be
    /* face in each roll */
  7. Page 319, line 5.
    ". as shown" "as shown"
  8. Page 325, line 10.
    returnType function(int m, int n, double [name][m][n])
    should be
    returnType function(int m, int n, double name[m][n])
  9. Page 333, lines 15-17.
    v = 0.88
    b = 2.17
    y is = 11.84 (m) at time t = 11 (s)

    should be
    v = 0.87
    b = 2.21
    y is = 11.83 (m) at time t = 11 (s)
  10. Page 334, line 14 from the bottom.
    double t_mean, y_mean, titm, sumty, sumts;
    should be
    double t_mean, y_mean, titm, sumty=0, sumts=0;
  11. Page 334, lines 5-6 from the bottom.
    sumty = titm*(y[i]-y_mean);
    sumts = titm*titm;

    should be
    sumty += titm*(y[i]-y_mean);
    sumts += titm*titm;
  12. Page 362, line 9 from the bottom.
    compare(a, a) and compare(a, b)
    should be
    compare(a, a, 4) and compare(a, b, 4)
  13. Page 368, line 12.
    int f(int m, int m, int a[m][n], int t[n][m]);
    should be
    int f(int m, int n, int a[m][n], int t[n][m]);
  14. Page 369, line 21.
    double vectsmul(int n, double v[n], double s, double b[n]);
    should be
    void vectsmul(int n, double v[n], double s, double b[n]);
Chapter 11
  1. Page 393, line 7.
    sum += (a+i); /* sum all alements one by one */
    should be
    sum += *(a+i); /* sum all elements one by one */
  2. Page 438, line 17 from the bottom.
    p2 = *a1[2];
    should be
    p2 = &a1[2];
  3. Page 440, line 15.
    "i-maxp and j-maxp" should be "i_maxp and j_maxp".
  4. Page 446, line 5 from the bottom.
    p = malloc(64);
    should be
    p = malloc(64);
    if(p == NULL)
       printf("Error: no memory\n);
  5. Page 447, lines 10-17.
    a. In Windows, type Ctrl-Alt-Delete key combination to bring up the Windows Task Manager, and check the memory size used by ch in the column of Mem Usage.
    b. In Linux and Solaris, type the command below in another window several times over the period of one minute. > ps -elf | grep leak
    c. In Mac OS X, type the command below in another window several times over the period of one minute. > ps -u | grep leak
    should be

    a. In Windows XP, type Ctrl-Alt-Delete key combination to bring up the Windows Task Manager, click Processes, and check the memory size used by ch in the column of Mem Usage. In Windows Vista or Windows 7, type Ctrl-Alt-Delete key combination, click Start Task Manager, click Processes, and check the memory size used by the command ch in the column of Memory.
    b. In Linux, at the startup menu, click System, click Admininstrator, click System Monitor, then check the memory size used by the command ch. In Linux and Solaris, you may also type the command below in another window several times over the period of one minute.

    > ps -elf | grep leak
    c. In Mac OS X, on the toolbar for Finder, click Go, click Utilities, click Activity Minitor, then check the memory size used by the command ch.
  6. Page 481, line 12.
    For example, if s1 is "letter", the function changes s1 to "rettel".
    should be
    For example, if s1 is "letter", the output s1 should be "rettel".
Chapter 13
  1. Page 502, line 9.
    "t[i] = t0 + i*(t0-tf)/(N-1);
    should be
    "t[i] = t0 + i*(tf-t0)/(N-1);
Chapter 14
  1. Page 602, lines 3-4.
    "The function feof() was introduced in Chapter 9. It tests"
    should be
    "The function feof() described in section 14.2 tests".
  2. Page 609, line 8.
    "char *contents = (char *)malloc(sizeof(stbuf.st_size));"
    should be
    "char *contents = (char *)malloc(stbuf.st_size);"
Chapter 15
  1. Page 661, line 24.
    "studentlistmenu.c" should be "studentlistfunc.c".
  2. Page 671, line 22.
    "tt tmp follows the node tt current" should be "tmp follows the node current".
Chapter 18
  1. Page 737, Exercise 3b.
    "the main() function" should be "the function main()".
Chapter 19
  1. Page 771, lines 10-11.
    "The set function" should be "The function set()".
Chapter 20
  1. Page 779, lines 4-5 from the bottom.
    "The position specified is the location of the top part of the space separating the markers and labels of the legend," should be "The position specified is the location of the top right of the box for the markers and labels of the legend,".
  2. Page 780. Figure 20.3 should be

  3. Page 792, line 9, line 15, and line 2 from the bottom. "in the same illustration" should be "in the same figure".
  4. Page 789, line 5-7 from the bottom.
    > g++ plotxy.cpp -I/usr/silib/include -L/usr/silib/lib -lchplot -lm
    > CC plotxy.cpp -I/usr/silib/include -L/usr/silib/lib -lchplot -lm
    > c++ plotxy.cpp -I/usr/silib/include -L/usr/silib/lib -lchplot -lm

    should be
    > g++ plotxy.cpp -I/usr/local/silib/include -L/usr/local/silib/lib -lchplot -lm
    > CC plotxy.cpp -I/usr/local/silib/include -L/usr/local/silib/lib -lchplot -lm
    > c++ plotxy.cpp -I/usr/local/silib/include -L/usr/local/silib/lib -lchplot -lm
  5. Page 792, lines 7-9.
    x(t) = 4(1-3t)e^(-3t)
    v(t) = -24e^(-3t) + 36te^(-3t)
    a(t) = 108(1-t)e^(-3t)

    should be
    x(t) = 4(1+6t)e^(-6t)
    v(t) = -144te^(-6t)
    a(t) = -144(1-6t)e^(-6t)
Chapter 21
  1. Page 831, line 7.
    "compute x, Y, and Z"
    should be
    "compute Y and Z"
  2. Page 831, line 10.
    "inside the function main()"
    should be
    "inside the function main()"
Chapter 22
  1. Page 837, line 13.
    "2s^4 - 3^3 + 191s^2 - 701s + 303"
    should be
    "2s^4 - 3s^3 + 191s^2 - 701s + 303".
  2. Page 840, line 14 from the bottom.
    "evectors and evectors" should be "evalues and evectors".
Chapter 23
  1. Page 872, line 9 from the bottom.
    t = linspace(t0, tf, N);
    should be
    t = linspace(t0, tf, n);
Appendix B
  1. Page 893, line 6.
    "float complex, double complex, and long double complex" should be "float complex, double complex, and long double complex"
  2. Page 893, line 7.
    "long long and unsigned long long" should be "long long and unsigned long long".
Index
  1. Page 897, line 2.
    "\' signal-quote-character escape sequence"
    should be
    "\' single-quote-character escape sequence".
  2. Page 901, line 26, 27, 28, and 29.
    "data2DCurve() 328, 775, 777"
    "data2DSurface() 777"
    "data3DSurface() 336"
    "data3DSurface() 336"
    should be
    "data2DCurve() 328, 775".
    "data3DCurve() 338, 777"
    "data3DSurface() 336, 777".
  3. Page 907, lines 1-2.
    oderk, 886
    oderk(), 422, 841
    should be
    oderk(), 422, 841, 886