C is widely used in many contexts. This training focusses on using C for scientific programming.
Learning outcomes
When you complete this training you will be able to
- read and understand well-written C code;
- write intermediate-level C programs;
- have a good starting point to familiarize yourself with the more sophisticated aspects of C;
- know about best practices and pitfalls for C programmers;
- have a working knowledge of the C standard Library;
- know how to use third-party libraries such as GSL for numerical computing.
Schedule
Total duration: 8 hours, split over two sessions.
Session one
Total duration: 8 hours
| Subject | Duration |
|---|---|
| introduction and motivation | 5 min. |
| basics: control flow statements, data types | 85 min. |
| hands-on session | 20 min. |
| coffee break | 10 min. |
| functions | 15 min. |
| simple I/O | 10 min. |
| arrays and user defined types | 85 min. |
| hands-on session | 20 min. |
Session two
Total duration: 4 hours
| Subject | Duration |
|---|---|
| pointers & dynamic memory management | 80 min. |
| hands-on session | 20 min. |
| error handling | 10 min. |
| coffee break | 10 min. |
| using third-party libraries | 80 min. |
| hands-on session | 20 min. |
| wrap up | 10 min. |
Training materials
Slides are available in the GitHub repository, as well as example code and hands-on material.
Target audience
This training is for you if you need to use C as a programming language.
Prerequisites
You will need experience programming in another programming language, This is not a training that starts from scratch.
If you plan to do C programming in a Linux or HPC environment you should be familiar with these as well.
Quick self-assessment
The tasks below are not meant to test prior C knowledge. They describe programming concepts you should already recognize from another programming language. If you can do most of them in any language, you are likely ready for this training.
- write a function that computes the average of a list of numbers;
- loop over a collection and compute a derived result such as a sum or count;
- use
if/elseor aswitch-like construct to classify values into cases; - split a program into a few helper functions or files;
- read data from a text file and print a simple summary;
- read a short program and explain what it does;
- compile or run a small program from the command line;
- make a small change to an existing program and run it again.
If several of these items still feel difficult, the training will probably move too fast. In that case, it is better to first take a short introductory programming course.
Software and access requirements
To follow hands-on, you need a computer with a C development environment installed. You can of course use an HPC system you have access to as well.
Level
- Introductory: 40 %
- Intermediate: 40 %
- Advanced: 20 %
Trainer(s)
- Geert Jan Bex (geertjan.bex@uhasselt.be)