e02 : Midterm 2
num | ready? | description | exam date |
---|---|---|---|
e02 | true | Midterm 2 | Thu 11/21 12:30PM |
Instructions for the exam
- You may bring one 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.
- You may add your notes to this COLLABORATIVE DOCUMENT.
- 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
- We will provide you the table of operator precedence
- The format of the exam will be similar to midterm 1
- Seating is assigned, check your seat prior to the exam here: Seating Chart for midterm 1
-
The layout of the room is available here
- Consolidated exam notes These cover some of the topics. Add to them to personalize your notes to bring to the exam.
Reference material
You are expected to know the material from the following lectures, labs and homeworks. Please be sure to review the code from lecture which can be found in the lecture notes (different from lecture slides)
Post Midterm material
Code written in lecture
https://github.com/ucsb-cs16-mirza/ucsb-cs16-f19-lectures
- Lecture 1 to 12, lecture 12 up to slide 10 (doesn’t include material on linked lists)
- Homeworks 1 to 7
- Labs 0 to 6
Pracice problems:
For topics on lectures 1-8, use the following practice problems. Please solve the problems on your own and don’t just refer to the provided solutions:
- Practice Problems -I
- Solutions to the practice problems -I
- Concept Inventory on Pointers and Arrays.
We recommend that you try these problems after you have studied/contributed to the collaborative notes (see above) and gone through the labs, homeworks and lectures.
Midterm Study Guide
- Write the skeleton of a simple C++ program - see the hello world example covered in lecture
- Write code that involves passing parameters to main
- Read and write to standard input, output with cin, cout - you should be able to write code that uses these concepts, identify the difference between cout, exit and return
- Simple unix commands (covered in labs): cp, mkdir, ls, pwd, cd
- An understanding of what compilers are, the compilation and execution process of C++ programs:
- What is g++? What are the inputs and outputs ?
- What is the difference between compiling and running a C++ program?
- How can you ask g++ to use the c++11 libraries when compiling your C++ program
- What are compile-time errors?
- What are run-time errors?
-
How to pass arguments to main refer to labs that used this concept
-
While loops, for loops, do while loops (very important)
- Functions
- An understanding of how parameters are passed to functions, and how values are returned from a function
- Difference between function that prints to output and function that returns a value
- Function declaration, definition and call
- Writing functions similar to those in the labs
- The ability to use variables and basic data types in the type of programs covered in class:
- Identify valid and invalid ways to name variables in C++ - Please refer to book on this
- Identify invalid use of variables: For example using a variable in an expression or assignment before declaring it
- Different ways of initializing variable:
int x =10; int x(10); cin>>x;
- Difference between variable declaration and initialization.
- What is the default value given to uninitialized variables in C++ and why this can be a problem
- The ability to debug and write code that involves flow control structures taught in class and used in labs. Pay attention to syntax, and the ability to use each appropriately to solve problems similar to those provided in the labs
- If else statements, multiway if-else statements
- For, while and do-while loops, nested for loops (used in lab02)
- Identify the occurrence of infinite loops
- 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 (run-time stack vs. heap) (general theme in all the following topics, almost every lecture talks about this)
- 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
- Arrays: hw 08, lab 04, lec 08, lec 09, lec11
- Pointers: hw 10, lab 05, lec 09
- purpose
- declaration, size of a pointer
- initialization to null value, initialization using ‘&’ 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: hw 08, lab 05, lec 10
- Definition
- Assignment
- Call by reference
- Differences between pointers and references (when would you use each and why)
- tracing/writing code involving pointers, references and showing program dynamics via pointer diagrams
- Structs: hw 10, lab 05, lec 10
- Defining a struct as a data type lec 10
- Declaring objects of struct on the stack lec 10
- Accessing memory variables using the dot (.) operator lec 10
- Pointers to structure (declaration and initialization) lec 10
- References to structure [See code covered in lecture]
- Arrays of structs [See code covered in lec 12]
- Passing structs to functions by value, address and reference [See code covered in lec 11]
- Passing arrays of structs to functions [See code covered in lec 11]
- tracing/writing code involving structs, pointers and references to structs, arrays of structs and showing program dynamics via pointer diagrams
- Program translation
- Steps (preprocessing, compiling, linking)
- Arguments to g++ (creating objectfiles, differences between object files and executable)
- Dynamic memory allocation: Use of new and delete. Stack vs. Heap (this is very important!!!)
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 18 Final exam
- Spring’18 -midterm 2
- Spring’18 - midterm 1
- Spring’18 Midterm 1 solutions
- Spring’17 - midterm 2
- Spring’17 Midterm 2 solutions
- Spring’17 - midterm 1
- Spring’17 Midterm 1 solutions
- Winter’17 - midterm 1
- Winter’17 Midterm 1 solutions
- Winter’17 - midterm 2 (Ignore questions in Part 3)
- Winter’17 Midterm 2 solutions