Scientific computing II b
530257, 5 ECTS
Fall 2011, Semester 2 of 4


Course grades can be found here.

C language co-creator Dennis Ritchie has died at age 70, Oct. 13, 2011. Link 1 Link 2 Link 3

Lecture and exercise times

Lecture times and location: Mondays and Tuesdays at 10:15 - 12:00.

Exercise times and location: Mondays at 14:15-16, room D211 in Physicum. Return homework to assistant(s) by e-mail by Monday at 12:00 (noon).


The course belongs to the set of compulsory studies in the MoMoNano Master's Programme started by the Department of Chemistry and the Department of Physics, at the University of Helsinki, Finland. MoMoNano is now a part of the Nordic Consortium in Computational Chemistry and Physics (NOCCAP).

Note to MoMoNano students: The course "Scientific programming" is listed as compulsory for you. This course does not exist anymore. The corresponding material and credits are earned by participating in the course "Scientific computing II b" and doing some additional work. The exact nature of this work will be decided by coordinator Janne Pesonen in conjunction with other responsible persons. The material covered in the courses "Scientific computing II a" and "Scientific computing II b" replaces the material covered in the no longer existing course "Scientific programming".

The course teaches advanced C programming, which can be applied to the solution of scientific problems, and some applications. At the end of the course the participants should be able to write, compile and run portable, bug-free and predictable C code that follows the ANSI C89/C90 standard.

Students are expected to have some practical familiarity with the concept of programming and especially how to use Unix/Linux systems. Participation in the course "Scientific computing II a" prior to this course is highly beneficial.

Note 1: Despite its name, this course is not primarly focused on computational methods. You may want to participate in the course Scientific computing III.

Note 2: The programming presented in the lecture notes and the model answers for the homework will be implemented on GNU/Linux systems.

Contents and literature


Ch  Title                                            Lecture
01  Introduction to C programming                    L1
02  Fundamental types                                L1
03  Basic output and input                           L2
04  Operators                                        L2,L3
05  Order of evaluation                              L3
06  Control statements                               L3
07  Arrays                                           L4
08  Functions                                        L4
09  Using a debugger                                 L5
10  Pointers                                         L5
11  Structures, unions, and enumerations             L5
12  Declarations                                     L6
13  Advanced use of pointers                         L6
14  Dynamic memory                                   L7
15  Strings                                          L7
16  Working with files
17  The preprocessor
18  Scope, linkage, and definitions
19  Modular programming                              
20  Introduction to the standard C library           
21  The float.h, limits.h and math.h headers         
22  Error handling                                   
23  Other library functions                          
24  Binary, octal, and hexadecimal systems           
25  Number representation and computational accuracy 
26  Code optimization                                
27  Linked lists                                     
28  Sorting                                          
Skipped:  29  Low-level programming                            
Skipped:  30  Stack, code, and data segments                   
Most of the basic contents should be familiar from the course "Scientific computing II a." The participants are expected to have taken part in that course, of otherwise master the material.

The lecture notes will serve as the "course book", i.e. all necessary material will be covered there. The course uses "The C Programming Language. ANSI C version." by B. Kernighan and D. Ritchie, as the source of standard C (ANSI C, C89/C90). Other supplementary books may be used:

  • "C programming: A modern approach" by K. N. King
  • "C primer plus", by S. Prata.


To pass the course about 50% of all points that can be earned from home assignments must be obtained. Standard grades from 1 to 5 are given based on points obtained from the home assignments as well as the final exam. The final exam may take the form of an extended home assignment.

Introductory material

First lecture

. [2 pages/A4]. [1 page/A4].

Lecture notes, exercise solutions, and exercise scores (authorization required)

Username and password can be obtained from the lecturer

Appendices, read when necessary:


Exercise assistant: Sergio Losilla (sergio (at)

Solutions to the exercises will be uploaded to the course website sometimes between noon and 14:00, provided there are no issues preventing it.

The solutions will not be thoroughly discussed in the exercises, unless (i) an exercise was particularly problematic, or (ii) someone requests a discussion for a particular exercise.

The exercise sessions will be more "programming laboratories". In the exercise session there will be some ideas for programs to play around with and apply what was shown in the lectures. If some concept was not completely clear from the lectures (those pesky pointers...) it can be discussed in the exercise session.

There are only 12 computers (and 25 chairs) in the room reserved for the exercises. Depending on how many people start showing up regularly, the work will have to be performed in pairs. You might be interested in bringing your own laptop, if you have one. If many people show up regularly we might need to have two exercise sessions. This may take time to set up --- if at all practically possible --- due to limited number of computer rooms and other people's timetables.

In exercises that consist of programming tasks, the source code of the programs should be sent as separate files. IF THE PROGRAM DOES NOT COMPILE ON using gcc 3.4.6 (the default version of gcc on that machine) YOU WILL GET 0 (ZERO) POINTS FOR THAT EXERCISE. So you might want to use all of the options -std=c89 -ansi -pedantic -Wall -W when compiling your code. YOU CAN ALSO USE gdb AND valgrind ON TO FIND ERRORS IN YOUR CODE.

Send text answers in plain text (directly on the email is fine) or in PDF format.

If you have questions, you can go to the exercise assistant's office (C117 in Chemicum in the Laboratory for Instruction in Swedish) on Thursdays at 10:00. If you need to come at some other moment, please write beforehand.

This page was last updated January 31, 2012, by Krister Henriksson (krister.henriksson (at)