Introduction to Programming
for
Scientific Computing

These are hints for someone rusty in C/C++ programming who wants to take the Scientific Computing course. Although C and C++ are quite different for some applications, this course makes little use of the object oriented features unique to C++. The reason to prefer C++ over C is that C++ is strongly typed, so type errors are flagged at compile time, which can save hours of debugging. Also, basic input and output may be simpler in C++. The reason to prefer C is that most books start with C and get to C++ only later. Also, formatting numerical output to line up in columns, which is very desirable in numerical computing, is more cumbersome in C++ than C. Take your pick.

First, you need access to a C/C++ compiler. I prefer a unix environment where the text editor and compilor are separate programs and I have to type "make ..." to compile. Others prefer integrated environments where the editor and compiler are part of the same software package. For a Windows box you can buy a compiler. I recommend Borland over Microsoft but there is not much difference between them. Also, there are quite good shareware compilers for Windows or Linux.

Next you need a book. I recommend "The C Programming Language" by Kernighan and Ritchie. Another good choice is the "C Programming" volume in the Schaum's outline series. For C++ there is the "C++ Primer" by Lippman, but you have to read part of Kernighan and Ritchie first.

Finally, you need to get started. Here is a sequence of exercises that you might try.