DarthDemono’s Notes for Imperative Programming L+Pr / IP-18fIMPROGEG

This course is not about problem solving. It is about understanding C as a language, how programs are compiled, and how the machine executes them. You are expected to understand what you write, why it works, and why it sometimes does not.

  • Course code: IP-18fIMPROGEG
  • Credits: 5

Setup (what you install + how you work)

Windows (MSYS2 + GCC + VSCode)

  1. Install MSYS2
  2. Update and install required packages (use any shell):
    pacman -Syu
    pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb mingw-w64-x86_64-make
  3. Add to %Path%
  4. Use VSCode as the editor (my recommendation, you can use vim or nano if you want)
    • Install the C/C++ extension
    • Make sure VSCode uses the MSYS2 gcc

Linux (native, WSL, or server)

  1. Install gcc

    sudo apt update
    sudo apt install gcc vim build-essential
  2. Editors:

    • vim
    • nano
    • VSCode (remote or local)

    Note: In Comsys server you are expected to use vim/nano and gcc will be pre-installed


Compilation rules

The instructor compiles using:

gcc -g -fsanitize="address,undefined" -fno-omit-frame-pointer -W -Wall -Wextra -pedantic -Werror *.c

This:

  • enables runtime checks
  • catches undefined behavior
  • treats warnings as errors

Windows limitation

-fsanitize does not work on Windows.

For local Windows practice, use:

gcc -g -fno-omit-frame-pointer -W -Wall -Wextra -pedantic -Werror *.c

Final verification

To be sure your code is correct, compile on:

  • WSL
  • or the comsys server
  • or a Linux VPS

If it fails there, it is not correct, even if it “works on Windows”.


End goal of the course

By the end, you should be able to:

  • Compile clean C code
  • Use pointers safely
  • Manage dynamic memory allocation correctly with malloc
  • Design and manipulate struct-based data structures
  • Avoid undefined behavior
  • Input and Output data correctly
  • Understand ‘run-time’ and ‘compile-time’ processes

Samples

Some samples for what to expect for Exams

particles

canvas


Lecturers / Instructors Recommendations

Books


2 items under this folder.