WEEK02
May 17 and May 19
This page contains lectures, examples and assignments for week 2
of the class "Introduction to Scientific Programming".
Lectures
Example Programs:
-
add_ints.cpp, a program which gets two integers from the user and adds them.
-
add_small.cpp, a program which sets X = 1.23456789, asks the user for a Y
value, and prints out X+Y to 12 digits. You may be interested to try Y = 1,
0.1, 0.01, 0.001, and so on. Eventually, Y becomes too small to make any
difference to X.
-
circle.cpp, a program which accepts coordinates (x,y) from the user,
and reports whether that point is inside the unit circle.
-
formula.cpp, a program which uses three integer variables, but which
gives each one a value in a different way.
-
formula2.cpp, a version of formula.cpp in which variable y is used
before it has been given a value.
-
gnu_input.txt, commands to GNUPLOT to create a plot.
-
hello.cpp, a program which says "Hello, world!".
-
precedence.cpp, a program which looks at how the rules of operator
precedence are applied, and how parentheses can override those rules.
-
sine_table.cpp, a program which prints out a table of values of 501 X
between 0 and 20, and the corresponding sines.
-
sine_table.png, a plot of the data.
-
sine_table.txt, a table of sine values.
-
surface_grid.cpp, a program to generate the surface plot data.
-
surface_grid_gnuplot.txt, X, Y, Z data for Gnuplot.
-
surface_grid_input.txt, commands to Gnuplot to make a plot.
-
surface_grid.png, the surface plot.
Assignments:
-
Tuesday: Read Chapter 2.1 to 2.4
-
Tuesday: There will be an in-class exercise.
-
Thursday: Read Chapter 2.5 to 2.8
-
Thursday: There will be a programming homework assignment.
You can go up one level to
the ISC course page.
Last revised on 19 May 2011.