- Docente: Francesco Barchi
- Credits: 3
- Language: Italian
- Teaching Mode: In-person learning (entirely or partially)
- Campus: Bologna
- Corso: First cycle degree programme (L) in Mechatronics (cod. 6009)
-
from Sep 15, 2026 to Dec 15, 2026
Learning outcomes
Students learn how to design an algorithmic solution to a given problem using the C programming language.
Course contents
The course covers the fundamentals of procedural programming using the C programming language. The main topics are:
- fundamental concepts of the Linux operating system;
- use of the terminal and the main shell commands;
- organization, compilation, and execution of a C program;
- use of the compiler and interpretation of error and warning messages;
- use of the debugger to analyze program execution;
- structure of a C program;
- variables, constants, operators, and expressions;
- representation of numerical data using the int, float, and double types;
- type conversions and the main issues related to numerical precision;
- branches: if, if-else, and switch ;
- loops: while, do-while, and for ;
- terminal input and output;
- arrays and matrices;
- strings and character arrays;
- definition, declaration, and invocation of functions;
- parameter passing and return values;
- scope and lifetime of variables;
- main features of the C standard library;
- pointers and the relationship between pointers and arrays;
- representation of structured data using struct ;
- reading from and writing to text files;
- management of command-line arguments using argc and argv ;
- design and implementation of simple algorithms;
- search algorithms;
- elementary sorting algorithms;
- dynamic memory allocation and deallocation;
- organization of a program into multiple source and header files;
- program verification and testing techniques.
The topics will be developed through progressively more complex exercises and practical laboratory activities, with particular emphasis on solving numerical problems, processing data acquired from sensors, and manipulating simple datasets.
Readings/Bibliography
Reference textbooks:
- Brian W. Kernighan, Dennis M. Ritchie, The C Programming Language, Second Edition, Pearson.
- H. M. Deitel, P. J. Deitel, C: How to Program, Ninth Edition, Pearson, 2022.
Additional teaching materials, including slides, code examples, and exercises, will be made available through the course’s online learning platform.
Teaching methods
The course is primarily laboratory-based. Teaching activities include:
- introductory lectures presenting theoretical concepts and programming tools;
- practical demonstrations of program writing, compilation, execution, and debugging;
- guided exercises carried out with the instructor;
- individual exercises completed independently;
- analysis and correction of programs containing errors;
- progressive development of programs of increasing complexity.
During the laboratory activities, students will be encouraged to design solutions independently, verify their behavior using appropriate test cases, and use the debugger to identify and correct errors.
Assessment methods
Learning outcomes will be assessed through an individual practical examination. During the examination, students will be required to design and implement one or more C programs aimed at solving problems consistent with the topics covered during the course. The assessment will consider the following aspects:
- correctness of the problem analysis and of the proposed algorithm;
- functional correctness of the program;
- appropriate use of C language constructs and data types;
- organization of the code using functions and data structures;
- correct management of input, output, and, where required, dynamic memory;
- ability to handle boundary cases and invalid input;
- readability, clarity, and modularity of the code;
- absence of undefined behavior, invalid memory accesses, and memory leaks.
To pass the examination, the program must correctly implement at least the fundamental required functionalities and demonstrate sufficient knowledge of the main constructs of the C programming language.
Teaching tools
For the laboratory activities, students will be provided with a workstation equipped with:
- a Linux operating system;
- a C compiler compliant with the language standards;
- a debugger;
- a text editor or integrated development environment;
- a terminal and shell;
- tools supporting program compilation and analysis.
Students may also use their own computers, provided that they are configured with tools equivalent to those used during the course. Instructions for configuring the development environment will be provided at the beginning of the course.
Office hours
See the website of Francesco Barchi