Exams

Midterm Details

Midterm Solutions

Solutions to 23au midterm

Midterm Policies

The midterm will be administered in-person during the scheduled lecture time on October 27, 2023.


Midterm Structure

This list is a summary of the topics we've covered in class so far that could potentially be on the midterm. Generally, if you've kept up with everything that's been covered in lecture, sections, exercises, and homework assignments you should be well prepared, and questions may be based on any of the work we've done this quarter. We may also ask you to reflect on exercises and/or homework you have already completed. A good way to study is to attempt some of the old exams in a quiet room and limited to the 50 min. time allowed for the real exam before looking at the sample solutions. Some of the practice exercises at the end of most lectures can also be useful for studying if you haven't done them already.

You should understand the ideas and core concepts and how to use them, but don't memorize API details. We'll provide hints or reference material on the exam for API details as needed, but you should know the basics.

The exam will be closed book, except that you may have one 3x5 (or smaller) index card with whatever notes you wish written on both sides for reference. The notes must be hand-written, i.e., no computer printouts, no scanned/reduced notes, and no electronic devices or other technology.

General program organization and where C fits in the ecosystem

  • System layers: C language, libraries, and operating system
  • General workflow needed to build a program – preprocessor, compile, link
  • Preprocessor – how #include, #define, #ifndef and other basic commands rewrite the program
  • Structure of C/C++ programs: header files, source files
    • Declarations vs definitions
    • Organization and use of header files, including #ifndef guards
    • Faking modularity in C – headers, implementations
    • Internal vs external linkage; use of static for internal linkage
    • Dependencies – what needs to be recompiled when something changes (dependency graph behind make and similar tools)
    • Make and makefile basics – how build dependencies are encoded in makefile rules
    • More tools: basics of using git for version control (add/commit/push, primarily), what to put in a repository and what to leave out

C language and program execution

  • Review: standard types, operators, functions, scope, parameters, strings, etc.
  • Extended integer types (int32_t, uint64_t, etc.) and when to use them
  • Standard I/O library and streams: stdin, stdout, fopen, fread, scanf, printf, etc.
  • POSIX libraries – wrappers for system calls
    • POSIX-layer I/O: open, read, write, etc.; basics of directory reading API
    • Relationship between C standard library, POSIX library functions, and system calls
  • Error handling - error codes and errno; error handling/retry for POSIX read/write
  • Process address space and memory map (code, static data, heap, stack)
    • Object lifetimes: static, automatic, dynamic (heap)
    • Stack and function calls – what happens during function call, return
  • Function parameters
    • Call by value semantics (including structs, pointers)
    • Arrays as parameters - pointers
    • Using pointers to approximate call-by-reference semantics
    • Function pointers as parameters
  • Pointers, pointers, pointers - &, *, and all that
    • Typing rules and pointer arithmetic (what does p+1 mean?)
    • Relationship between pointers and arrays, a[i] and pointer arithmetic
    • String constants, arrays of characters, C string library
    • Using void* as a “generic” pointer type
    • Casting
    • Dynamic allocation (malloc, free)
    • Potential bugs – memory leaks, dangling pointers (including returning pointers to local data), etc.
    • Be able to draw and read diagrams showing storage and pointers, and be able to trace code that manipulates these things.
  • Structs – how to define and use; meaning of p->x  ( = (*p).x ); structs as local variables, parameters, and return values (value semantics) vs. heap-allocated structs; struct values vs pointers to structs
  • Typedef – how to define and use
  • Linked data structures in C – linked lists, hash tables, etc.

C++

  • Classes and modularity, namespaces
    • Be able to read and create simple class definitions and add to them, implement functions, trace code, etc.
    • Know the difference between constructors, copy constructors, and assignment and when these are executed
    • Know what a destructor is and when it gets executed and what it should do
  • Other basic differences from C
    • Simpler, type-safe stream I/O (cout, cin, <<, and >>)
    • References – particularly reference parameters
    • More pervasive use of const (const data and parameters, const member functions)
  • Other topics not reached until right before the exam will not be included on the midterm

Midterm Samples

Important Note: This quarter's midterm exam occurs earlier than past quarters to avoid the added stress of multiple large homework assignments due around the same time. Be sure to refer to the topics covered (above) since many of the sample midterm exams test knowledge on concepts we have not yet covered in detail.

  • Old midterms: 22sp (solution) 19wi (solution) 18au (solution) 18su (solution) 17au (solution) 17su (solution)
  • Older midterms: 17sp (solution) 16su (solution) 16sp (solution) 16wi (solution) 15su (solution) 15sp (solution)
  • Final Details

    Final Solutions

    Solutions to 23au final

    Final Policies

    The final will be administered in-person on December 13 from 2:30pm-4:20pm in KNE 110.


    Final Structure

    The final will pick up where the midterm left-off. Any topics not covered by the midterm may be on the final. The exception is that you will not be responsible for the material nor concepts covered for the first time in the bonus lectures; those are just for your benefit and development as a systems programmer. As with the midterm advice, if you've kept up with everything that's been covered in lecture, sections, exercises, and homework assignments you should be well prepared, and questions may be based on any of the work we've done this quarter (except bonus lectures), but questions will focus on topics not tested by the midterm. We may also ask you to reflect on exercises and/or homework you have already completed. A good way to study is to attempt some of the old exams in a quiet room and limited to the time allowed for the real exam before looking at the sample solutions. Some of the practice exercises at the end of most lectures can also be useful for studying if you haven't done them already.

    You should understand the ideas and core concepts and how to use them, but don't memorize API details. We'll provide hints or reference material on the exam for API details as needed, but you should know the basics.

    The exam will be closed book, except that you may have one 3x5 (or smaller) index card with whatever notes you wish written on both sides for reference. The notes must be hand-written, i.e., no computer printouts, no scanned/reduced notes, and no electronic devices or other technology.

    Final Samples

  • Old finals: 19wi  (solution) 18au  (solution) 18su  (solution) 17au  (solution) 17su  (solution) 17sp  (solution)
  • Older finals: 16su  (solution) 16sp  (solution) 16wi  (solution) 15su  (solution) 15sp  (solution)