e02 : Midterm exam - II
num | ready? | description | exam date |
---|---|---|---|
e02 | true | Midterm exam - II | Thu 11/15 02:00PM |
Instructions for the exam
- You may bring one handwritten 8.5” x 11” piece of paper with notes on both sides. This paper will be collected along with your exam, so make your own copy if you would like to keep it.
- No calculators or phones are allowed in the exam
- There are no makeups for this exam
- You must write your name on every single sheet of paper including your notes
- We will provide you with scratch paper
- The format of the exam will be similar to Midterm 1
Topics Covered
The emphasis is on files, pointers, references, arrays, structs, and pointers to basic/struct types.
- Lecture 1 to lecture 12
- Homeworks 1 to 6
- Labs 0 to 5
Study Guide
- Memory
- Basic model of memory (addressable bytes)
- Representing multi-byte data like ints, address of multi-byte variables
- Program layout in memory during runtime
- Interaction of programs with memory
- Data representation:
- Conversions between difference bases using positional encoding (hex decimal binary)
- Finding the range of values with fixed numbers of bits for unsigned representation
- Git:
- Basics of
git
from the command line - Adding files to a commit, commiting with a commit message, sending and retrieving information from the remote server, etc.
- Basics of
- Arrays:
- declaration
- initialization
- representation in memory
- accessng elements via index-based and range-based for loops
- passing arrays to functions
- tracing/writing code involving arrays and showing program dynamics via pointer diagrams
- Files:
- Reading/writing to files using
ifstream
/ofstream
- Appropriately checking for errors/end of file
- Reading/writing to files using
- Pointers:
- declaration, size of a pointer
- initialization to null value, initialization using the ‘&’ operator
- pointer diagrams showing relationship between pointer and pointee
- derefencing pointers using the ‘*’ operator
- assignment involving pointers: making two pointers point to the same object
- changing where a pointer points to
- tracing/writing code involving pointers and showing program dynamics via pointer diagrams
- References:
- Definition
- Assignment
- Call by reference
- Differences between pointers and references
- tracing/writing code involving references and showing program dynamics via pointer diagrams
- Structs:
- Defining a struct as a data type
- Declaring structs
- Accessing memory variables using the dot (.) operator
- Pointers to structure (declaration and initialization)
- References to structures
- Arrays of structs
- Passing structs to functions by value, address, and reference
- Passing arrays of structs to functions
- tracing/writing code involving structs, pointers, references to structs, and arrays of structs; and showing program dynamics via pointer diagrams
Homework solutions
Past exams
You may also refer to all the past exams. Please note that some questions on these exams may refer to labs that you have not completed so far. You will only be asked questions related to the labs you have completed. The past exams should however provide some information on the expected difficulty and approximate format of the exam. Please note that there may be differences in content as well.
- Spring’17 - midterm 2
- Spring’17 Midterm 2 solutions
- Winter’17 - midterm 2 (Ignore questions in Part 3)
- Winter’17 Midterm 2 solutions
- Prior to W17