EPL232: Programming Techniques and Tools

Instructor: Andreas Aristidou
Type: Undergraduate (Compulsory)
Prerequisite: EPL131 - Programming Principles I
Lectures A: Tuesday & Friday, 09:00-10:30 (ΧΩΔ01 #104)         Lectures B: Tuesday & Friday, 10:30-12:00 (ΧΩΔ02 #Β204)
Recitations A: Wednesday, 09:00-10:00 (ΧΩΔ02 #014)             Recitations B: Wednesday, 10:00-11:00 (ΧΩΔ01 #103)
Laboratory: Tuesday, 14:00-16:00 or 16:00-18:00 (ΘΕΕ01 #Β103 or ΘΕΕ01 #103)
Teaching Assistants: Pavlos Antoniou and Pyrros Bratskas
This lecture has been structured based on the notes of the Associate Professor Demetris Zeinalipour.


The course teaches intermediate and advanced programming concepts, techniques and tools through a language that compiles to machine code. The course familiarizes the students with advanced programming constructs utilized for handling memory and files. Advanced topics in compilation, debugging, documentation and optimization of software. Methodological aspects in developing large-scale system software that addresses complex problems. Basic commands for programmers in the UNIX operating system.


Sign-up now to Moodle using code handed out in class!


  • Introduction to C for Programmers: types x86/x64, loops, selections, expressions, arrays, functions, IO, basic program organization,
  • Advanced C programming constructs: program anatomy and processes, memory and addresses (pointers, pointers and arrays, strings and examples), structures, unions and enumerations. Linear and non-linear programming data structures (dynamic memory allocation, lists, queues, doubly-linked lists, trees, applications and examples).
  • Advanced Compilation Topics and Tools: preprocessor directives, compiling multiple files with makefiles, static (.a) and dynamic (.so) linking of object files (.o), error handling (assert.h), static and dynamic code analysis (valgrind and gprof).
  • low-level programming (binary operators and examples, binary files and hexdump).
  • Basic commands for programmers in the UNIX operating system: file system, redirection and pipes, permissions and basic filters.
You can download the syllabus of the course here...

Course Schedule and Lectures

  1. Introduction: Syllabus & Basics Course Objectives and Syllabus, C Advantages and Drawbacks, Comparing C with JAVA, First Program, Directives, Functions, Statements, Compiling C Programs with GCC, Native vs. Intermed. Compile [C/C++/Objective-C vs. JAVA/Android/C#], Basic Data Types, basic comments, x86/x64 data types basics, reserved identifiers. [PDF | 1.43 MB]
  2. Fundamentals I: Formatted I/O, Expressions, Selection Statements, Loops The printf() and scanf() functions, Arithmetic Operators, Assignment Operators lvalues), Incr/Decr Operators, Expression Evaluation (precedence and order), Logical Expressions and _BOOL (C99), if..else, dangling-else, switch ... break, Loops (while, do, for, break, continue, goto). [PDF | 0.63 MB]
  3. Fundamentals II: Basic Types, Arrays and Functions Integer, Float, Character Types on x86 and x64 platforms, Type overflow and explanation, Type Conversion (Implicit and Casting), Type Definitions with typedef, The sizeof operator, 1-d arrays and m-d arrays: subscripting, initialization, sizeof. [PDF | 2.21 MB]
    Recitations I [PDF | 0.28 MB]
  4. Program Organization Local Variables (auto vs. static), External Variables, Blocks {}, Scope, Organizing a C Program, Comments with Documentation Systems (doxygen), Files: fopen, fread, fwrite, examples with srand(), rand() and time(NULL). [PDF | 1.12 MB]
  5. Memory I: Pointers Pointer Variables: Declaring and Using, Address (&) and Indirection Operators (*), Pointer Assignment (=), Pointer as Arguments, Using Const to protect arguments, Pointers as Return Values. [PDF | 1.01 MB]
    Recitations II [PDF | 0.29 MB]
  6. Memory II: Pointers and Arrays Pointer Arithmetic (adding, comparing), Pointers Variables and types, Using Pointers for Array Processing, Combining increment (++) and indirect (*) operators, arrays-functions-pointers, pointers and multi-dimensional arrays ((*p)[i]): working with rows, working with columns, sum example in five different ways. [PDF | 1.18 MB]
  7. Memory III: Strings, Array of Pointers and Examples String Literals and Variables, Reading and Writing, Implementing strcpy(), strlen(), strcat(), strcmp(), Arrays of Strings, Command Line Arguments (argc and *argv[]). [PDF | 1.16 MB]
    Recitations III (Corrected!!!) [PDF | 0.18 MB]
  8. Memory IV: Structures, Unions and Enumerations Structures: Representation, Initialization, Types, Nested Structures and Arrays, Examples, Pointer-to-Structures (*p).field | p->field), Memory Alignment Issues (__attribute__ ((__packed__))); Unions: Representation, Initialization, Examples and Applications; Enumerations: Representation, Examples and Applications. [PDF | 1.27 MB]
  9. Memory V: Dynamic Storage Allocation Dynamic Storage Allocation Functions, NULL, Dynamically Allocation Functions: malloc, calloc and realloc, Examples with Strcat, Deallocating Storage: free function, Dangling Pointer Problem, Pitfalls and Examples. [PDF | 0.72 MB]
  10. Program Structures I: Basic Linked-Lists, Pointer-to-Pointer and Stacks / Queues Data structures: introduction and examples, self-referential structures, constructing a basic linked-list, pointer-to-pointer (void **a) and dynamic multi-dimensional matrices, Stack: Basics and Definitions, Implementing a stack with dynamic memory allocation, Queue: Basics and definitions, Implementing a queue with dynamic memory allocation. [PDF | 0.52 MB]
    Recitations IV [PDF | 0.25 MB]
  11. Writing Large Programs Source Files: Reverse Polish Notation (RPN) Problem and Solution with Stack in 1 file, Organizing a Program in Multiple Files (RPN with 3 .c files), Compiling Multiple Files with GCC, Header Files: RPN problem with def.h, Pre-processor Directive: #include, Variables in Multiple Files and extern. [PDF | 0.46 MB]
  12. Writing Large Programs and the Preprocessor Nested Includes and Hierarchies, Protecting Header files with #ifndef..#endif, 9 Steps for Breaking a Program into Multiple Files, Examples (justify and RPN), Automating Compilation with Makefiles, A Generic Makefile and eClipse Makefiles, Preprocessor Directives: #include and #define in further detail, usage examples, parameterized macros: examples, advantages and disadvantages. [PDF | 0.78 MB]
  13. Program Structures II: Linked-Lists Ordering of data in Linked-lists (limitations of stacks, queues), Implementing Sorted Linked-list Functions: printList, Recursive functions. [PDF | 1.42 MB]
  14. Program Structures III: Additional Linked-Lists Functions and Examples Linked-Lists functions (recursive and repetitive implementations): insert, delete, eliminateDuplicates, mergeLists [PDF | 1.40 MB]
  15. Program Structures IV: Doubly-linked Lists Doubly-linked lists: Declarations and Definitions, Implementing put(l,x,y) recursively and repetitively, Doubly-Sorted Linked-lists: implementing printlist(l), insert(l,x) and delete(l,x), Circular linked list. [PDF | 1.34 MB]
    Recitations V [PDF | 1.13 MB]
  16. Tools I: Large-scale Software, Modules & Libaries, Testing Large-scale software and problems (source-lines-of-code SLOC and real examples), Modules and Libraries: Information Hiding and Abstract Data Types, Design Issues for Abstract Data Types, Cohesion and Coupling, Module Types: data pool, libraries static (.a) and dynamic (.so, .dll), abstract objects, abstract data types. Testing: Drivers, assert.h and Assertions, Unit Testing with tools: CUnit (for C) and JUnit (for JAVA), Dynamic Program Analysis (program performance): Static vs. Dynamic program analysis, Profiling Tools: Valgrind, gprof (for C) and JProfiler (for JAVA). [PDF | 2.20 MB]
  17. Tools II: Team Development, SVN and Open Source Software Development Software Versioning and Revision Control Systems: Tools (open and proprietary), SVN Architecture, Connecting to our SVN through eClipse, UNIX, operating system and web browser, SVN strategies: lock/modify/unlock, copy/modify/merge, Open-Source Software (OSS): examples and incentives, Free OSS, Licences for Free OSS (MIT, BSD, GPL and LGPL), Use cases: bestzip, cyimg, linux, Source code Preamble for MIT, GPL and FreeBSD licences. [PDF | 3.30 MB]
  18. Selected Topic I: Low-level Programming I Bitwise Operators, Using Bitwise operators to access bits and basic operations (setting a bit, clearing a bit, and testing a bit), names in masks. [PDF | 1.65 MB]
  19. Selected Topic II: Low-level Programming II XOR encryption example, Bit fields in structures, how bit fields are stored with and without memory alignment issues, complete previous lectures. [PDF | 1.28 MB]
  20. Basic Unix System Commands: Directory/File handling (mkdir, rmdir, cp, mv, rm), File Display and Conversion (file, head, tail, cat, more, wc, sort, uniq, iconv), In/Out Streams (stdin, stdout, stderr), File Redirection, Piping. [PDF | 1.71 MB]
    Recitations VI [PDF | 0.81 MB]
  21. Unix Commands and System Utilities I: UNIX commands (echo, touch), Ownership and Access Rights(chmod, chgrp, chown, umask, suid, sgid, sticky bit), Regular Expressions in BRE and ERE (grep, egrep), Usage and Examples. [PDF | 2.53 MB]
  22. Unix Commands and System Utilities II: Process Control (jobs, ps, fg, bg, kill, top), Find File and Program (which, whereis, find, exec, xargs), UNIX Commands (alias, cut, tr, tee, mail, comm, diff, crontab). [PDF | 2.01 MB]

Lab Schedule

  1. Tools Moodle, Cygwin, Eclipse CDT, GCC Basics
    Exercises Basic Programs & Fundamentals (operators, conditionals) [ZIP | 0.32 MB]
  2. Tools Google style guide (naming, formatting, comments), Using Doxygen to generate javadoc style comments for C programs
    Exercises Fundamentals (files, loops, functions) through examples with string.h [ZIP | 1.84 MB]
  3. Exercises Fundamentals (tables, pointers) with emphasis on pointers [ZIP | 0.09 MB]
  4. Exercises Re-implement string.h library using pointers (string length, string copy, string concat, substring, string compare) [ZIP | 0.15 MB]
  5. Exercises Dynamic allocation, structs, enum, union (implementing a shape, a sparse matrix data structures, small database) [ZIP | 0.13 MB]
  6. Exercises Stacks and Queues to solve different problems (Josephus problem, Balancing parentheses) [ZIP | 0.13 MB]
  7. Exercises Multiple file organization, makefile (infix to postfix expression, Balancing parentheses) [ZIP | 0.09 MB]
  8. Exercises Macros, conditional compilation, pre-processor directives & Linked lists operations: length(), print(), next(), previous(), retrieve(), locate(), insert(), delete() [ZIP | 0.95 MB]
  9. Tools Dynamic code analysis: Valgrind, gprof [ZIP | 282 KB]
  10. Exercises Binary files, hexdump command, binary files and linked lists, __attribute__((packet)). Low-level programming: Bit twiddling hacks [ZIP | 0.7 MB]
  11. Exercises Unix commands [ZIP | 81 KB]
  12. Exercises Unix commands [ZIP | 98 KB]


All Assignments will be announced in Moodle. Sign-up using the code handed out in class!

Text Book and Bibliography

Links and Manuals

To be uploaded soon...

© 2017 Andreas Aristidou