Procedural Programming with C

Undergraduate course, Giresun University, Department of Computer Engineering, 2023

procedural programming with c C is a general-purpose programming language widely used in systems programming, embedded software, operating systems, compilers, and performance-sensitive applications. It combines portable high-level constructs with low-level access to memory and hardware-related operations. C gives programmers substantial control over data representation, memory allocation, and program execution. This control can enable efficient software, but it also requires careful handling of memory, types, and undefined behavior.

Ders Öğretim Planı


Announcements


Course resources

  • V22.0201 Computer Systems Organization course

Preliminary Materials:

  • Prerequisites for preparation pdf
  • Key figures who have shaped the field pdf

Chapter 1: Introduction to C Programming

  • Origins and evolution of the C language
  • Features and benefits of using C
  • Setting up a development environment
  • Basic structure of a C program
  • Variables, data types, and operators
  • Input and output functions
  • Compilation process and execution

🗒️Lecture Notes


Chapter 2: Control Flow

  • Decision-making statements (if, else if, switch)
  • Looping statements (for, while, do-while)
  • Break and continue statements

🗒️Lecture Notes


Chapter 3: Arrays and Strings

  • Declaring and initializing arrays
  • Manipulating arrays: accessing, modifying, and traversing
  • String manipulation and string library functions

🗒️Lecture Notes


Chapter 4: Functions

  • Function declaration, definition, and calling
  • Function parameters and return values
  • Recursive functions

🗒️Lecture Notes


Chapter 5: Pointers

  • Understanding pointers and memory addresses
  • Pointer declaration and initialization
  • Pointer arithmetic
  • Dynamic memory allocation with malloc, calloc, realloc, and free
  • Checking allocation failures
  • Memory leaks, dangling pointers, and double-free errors
  • Ownership and lifetime of dynamically allocated memory

🗒️Lecture Notes


Chapter 6: Structures

  • Structure declaration and initialization
  • Accessing structure members
  • Nested structures and arrays of structures

🗒️Lecture Notes


Chapter 7: File Handling

  • Working with files in C
  • Opening, reading, and writing files
  • File positioning and error handling
  • File I/O using standard libraries

🗒️Lecture Notes


Chapter 8: Enumerations, Unions, and Bit-Level Operations

  • Enumerated types
  • Type aliases with typedef
  • Unions
  • Bitwise operators
  • Bit masks and bit manipulation
  • Bit-fields and their portability limitations

🗒️Lecture Notes


Chapter 9: Preprocessor Directives

  • Macros and their usage
  • Conditional compilation
  • Separating declarations and definitions
  • Designing header and source files
  • Include guards
  • Avoiding multiple-definition errors
  • Building multi-file programs
  • Debugging using preprocessor directives
  • Scope and lifetime of variables
  • Local, global, and static variables
  • Internal and external linkage
  • The const, static, and extern qualifiers

🗒️Lecture Notes


Chapter 10: Advanced Concepts - Part 1

  • Memory management techniques
  • Function pointers and callbacks
  • Understanding static and dynamic libraries
  • Recursion: principles and applications
  • Call stack behavior in recursive functions
  • Base cases and recursive cases
  • Recursion depth and stack overflow
  • Recursive versus iterative solutions

🗒️Lecture Notes


Chapter 11: Advanced Concepts - Part 2

  • Introduction to data structures (linked lists, stacks, queues)
  • Implementation and usage of data structures
  • Introduction to algorithms (sorting, searching)
  • Time and space complexity analysis
  • Variadic functions
  • Program arguments with argc and argv
  • Program termination and exit status

🗒️Lecture Notes


Chapter 12: Error Handling and Debugging

  • Common compile-time, link-time, and runtime errors
  • Checking function return values
  • Error reporting with errno, perror, and strerror
  • Assertions with assert
  • Defensive programming techniques
  • Debugging with compiler warnings and debugging tools
  • Introduction to sanitizers and static analysis

🗒️Lecture Notes


Chapter 13: Introduction to C++ (Optional)

  • Basic differences between C and C++
  • Introduction to object-oriented programming
  • Classes, objects, and constructors
  • Basic input/output in C++

🗒️Lecture Notes


Chapter 14: Project and Review

  • Individual or group project using C programming concepts
  • Review of key concepts and topics covered throughout the course
  • Q&A session and final assessment

Sample projects
🗒️Questions and answers
🗒️Multiple choice questions