Complete C coverage.
This book completely covers the C language in Part I with more 700 pages, which is organized
cumulatively so that each chapter builds information presented in the
earlier chapters. Each chapter itself is organized cumulatively so that
each section uses information provided in the previous sections. A single
topic is presented in a section first, and then reinforced and cross-referenced
in other sections and chapters. Beginners can skip sections and chapters
marked with the double dag symbol
in the title without hindering the
learning of the later chapters. These materials, however, are very useful
for those who plan on serious software development in C or intend to take
other advanced courses. The text is logically organized, and heavily
cross-referenced and indexed to serve as a reference for serious programmers.
Only two programs in Part I used extended features in Ch over C for simplicity of programming.
Program 4.6 uses the format specifier "%b" in Ch to print out data in binary number.
Program 4.7 is a much compplicated equivalent C program.
Program 10.30 uses the function linsolve() in Ch to solve a system of linear equations.
Program 10.31 is an equivalent version in C.
Extensive coverage of major C99 features.
C99 features of variable length arrays (VLA), type generic functions, IEEE
754 floating-point arithmetic, complex numbers, and new data types bool
and long long are used for numerical computing. They overcome the
shortcomings of C89 for solving problems in engineering and science.
Plotting for visualization.
A picture is worth a thousand words. Graphical plotting is essential
for applications in engineering and science. A plotting C++ library is
used for visualization for solving many problems in engineering and
science in both the text and exercises. All plots including those in
exercises were generated using simple functions or member functions in
this plotting library.
Multiple forms of presentation.
Many illustrations are used to clarify difficult concepts
and programming features such as expression evaluation order, pointers, arrays, structures, byte order, and
dynamic data structures (singly linked list, doubly linked list, circularly linked lists, stacks, queues, and binary trees).
Flowcharts, pseudocode, and procedures are used to describe complicated
Multiple versions for example programs.
Earlier example programs are gradually rewritten to make
them more concise, efficient, powerful, useful, or user friendly. This way, students do not struggle
with trying to understand new features and new programs at the same time.
Teaching and learning by examples with over 350 well-documented complete sample programs of more than 14,000 lines of code.
These programs show
various features of C and
a disciplined approach including how to document source code on-line,
how to overcome the numerical inaccuracy of floating-point numbers,
and algorithm development
for solving problems
in engineering and science. Many of these programs are derived from
the real-world production code.
In addition, many succinct C code and statements are executed
interactively with output in Ch to
illustrate numerous programming features and concepts.
Over 500 carefully designed exercises as homework problems.
These exercises for solving many
problems in engineering and science reinforce concepts presented in the text. Each chapter contains
exercises asking students to find potential trouble spots and likely errors. Abundant exercises are
designed for teaching multiple sessions without repeating problems.
Cross-platform software development.
All code examples in Parts I and II have been tested in Windows,
Linux, Mac OS X, Solaris, HP-UX, FreeBSD, and QNX in both the C/C++ interpreter Ch
and C/C++ compilers. The implementation and platform-specific issues are presented with examples
throughout the book in sections titled "Making It Work" at the end of each chapter in Parts I and
II. These sections illustrate how to use C/C++ interpreter Ch and ChIDE to execute C and C++ programs.
They describe the processes and options on how to compile and link C/C++ programs using
Visual C++ in Windows, gcc and g++ in Linux, and cc and CC in Solaris through ChIDE, command shell and make files.
Building and distributing static
and dynamic libraries using make files on these different platforms is also demonstrated.
64-bit machines are becoming increasingly popular. This book addresses how
to write portable C code for machines with a different number of bits. Whenever the code produces
different results for 32-bit and 64-bit machines, it is pointed out in the text.
Extensive coverage and unique presentation of difficult concepts.
Difficult topics such as arrays,
pointers (pointers to pointers, pointers to functions, pointers to arrays,
arrays of pointers, dynamical allocation of multi-dimensional ararys, passing arrays of variable length using poiners to pointers, generic pointers, how to find if a program has a memory leak in different platforms), binary and text mode for accessing files, byte order (endianness), structure alignment,
dynamic data structures (singly linked list, doubly linked list, circularly linked lists, stacks, queues, and binary trees), developing and distributing
static and dynamic libraries in Windows and Unix, and hardware interfaces are thoroughly covered using
multiple forms of presentation with many sample application programs.
Top-down and bottom-up software development is presented with real-world application examples.
The book is culminated by three interactive menu-driven GPA programs gradually rewritten with structures, arrays,
dynamic data structures of singly linked lists,
and data files
using static and dynamic GPA libraries. Old application programs would still work without any modification whereas
the underlying GPA library is gradually rewritten with new features for new applications.
The modular programming and code reuse are clearly illustrated by
these application programs.
LAPACK (Linear Algebra PACKage) written in Fortran and its C version, CLAPACK, are introduced.
How to use this most commonly used numerical library for linear systems is presented with examples.
Mixed-language programming with both row-wise and column-wise arrays is addressed.
Commonly used Unix commands are used for cross-platform software development.
Commonly used Unix commands such as
cc, gcc, g++, c++, CC, ld, make, ls, cd, mkdir, pwd, cp, rm, chmod, man, more, diff, wc, hexdump, ps, grep, xhost, ar, ranlib, ln, zip, unzip, gzip, and tar are introduced in the book for cross-platform software development.
In addition, the input/output redirection and pipeline are introduced at the beginning for
using data files in programs.
Object-based programming in C++ is introduced in Part II.
Essential features of C++ for applications in engineering and science are covered.
A C++ class for graphical plotting is introduced as an example of application of C++.
Numerical computing in Ch using computational arrays as first-class objects and advanced numerical
functions are introduced in Part III.
They can be used conveniently to solve ODE, non-linear
equations, linear algebra, etc. for complicated problems in engineering and science.
MATLAB is introduced in Part IV as a second programming language in comparison with C and Ch.
Part IV contains a thorough introduction to MATLAB
and comparison study with C and Ch for numerical computing.
With a solid foundation in computer programming in C, students can pick up any other languages and mathematical packages such as MATLAB or Mathematica quickly.
Part IV can also serve as a quick reference for programming in MATLAB for C programmers.
Fortran is introduced as a second programming language in comparison with C.
The chapter is available in
a PDF file from the website
for the book.
Once you have learned C, you will be able to quickly learn Fortran
by reading this chapter.
The comparison study presented in this chapter will also be very useful
for those who have the prior programming experience in Fortran to learn C.
Companion CD contains
C/C++ interpreter Ch Student Edition including
A C/C++ interpreter Ch can
be used for interactive execution of C expressions, statements, functions, and programs. It can be used by students
or instructors in classrooms for quick testing and trying difficult C features such as pointers and arrays.
It is especially suitable for beginners to learn internal representation of integral and floating-point numbers, programming concepts of selection statements, loops, functions, arrays, and pointers. Ch environment for Windows
also contains nearly 250 commonly used Unix commands such as
vi, ls, rm, make, awk, sed, zip, unzip, gzip,
can also be used by students to learn Unix in a familiar Windows environment
for a smooth transition from Windows to Unix.
ChIDE is especially developed for beginners without any previous programming
experience to learn how to design and debug C/C++ programs.
It allows the user to edit and interpretively execute C/C++ programs
in a user-friendly integrated development environment.
It can execute functions and programs with detailed line-by-line and step-by-step traces.
It can also invoke C and C++ compilers to compile and link C/C++ programs, then run the created binary executable programs.
The CD also contains
a complete reference manual in a PDF file and sample demo C source programs for all functions in the C standard libraries.
Using multiple colors in the book.
For clarity of the presentation, multiple colors are used in the book. 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.