Introduction Mathematical Computing
The required text for the course is:The C (ANSI C) Programming Language, Second Edition by Kernighan and Ritchie.We will systematically work through all the material in the book and place particular emphasis on similarities and differences from Matlab.
Prentice Hall, ISBN 0-13-110362-8
Homework will be assigned when the class meets on Friday, and it will be due the following Friday. The assignments will be emailed and recorded on the Homework page. All program files should contain comment lines with your name and the date.
Sample ProgramsHello world version 1.
No return character.
Hello world version 2.
Return character added.
Fahrenheit to Celsius version 1.
This version illustrates that the integer result of 100/180 is zero. It also uses the documented variables - lower, upper, and step - instead of burying the "magic" numbers 0, 300, and 20 in the code.
Fahrenheit to Celsius version 2.
This version provides a better integer result for the conversion by first multiplying all the terms in the numerator and then dividing by 9.
Fahrenheit to Celsius version 3.
This version declares the variables - fahr and celsius - to be floating point numbers instead of integers. It also adjusts the format string so that only the integer portion of fahr is displayed right justified in a field 4 characters wide, and celsius is displayed right justifiec in a field 6 characters wide with two digits to the right of the decimal point.
Fahrenheit to Celsius version 4.
In this version, the variables - lower, upper, and step - are initialized in the declaration statement. The while loop is replaced by a for loop. And, the construct "fahr = fahr + step" is replaced by the construct "fahr += step".
Fahrenheit to Celsius version 5.
In this final version, the variables - lower, upper, and step - are replaced by the symbolic constants - LOWER, UPPER, and STEP. In addition, the variable - celsius - is deleted and the calculation is done in the call to the printf function. Using upper case characters for symbolic constants is merely a widely used convention. It is not required by the definition of the C language.