e02 : Midterm exam - II
num | ready? | description | exam date |
---|---|---|---|
e02 | true | Midterm exam - II | Thu 05/23 05:00PM |
Logistics
- Bring studentID and writing utensils
- Preferable dark led
- PLEASE WRITE LEGIBLY
- No electronic devices, No book
- 1 double-sided 8"x11" sheet of handwritten notes
- please don't staple them or write on two sheets
- write your name and PERM# on the top right corner on both sides
Format
- Similar to midterm 1 (more or less)
- Possible types of questions
- Short answers
- Explain, describe, define, ...
- Write some code
- Fill in the blank
- True / False (if false, explain)
- Given code, write the output
- Covers a broad range of topics, but probably not everything.
Topics
Check the book and lecture notes for example problems.
File IO
- reading and writing from / to files
C++ build process
- Breaking code into multiple files (.cpp , .h)
- Preprocessing vs. Compilation vs. Linking
- Makefiles
- General syntax
- Conceptual understanding
- Simple g++ compilation rules
TestDriven Development
- Write a test that does ...
- Given tests, which ones pass
- Explain Test Driven Development ...
Arrays
- Declaration
- Syntax
- Reading / writing elements
Number Conversion
- Any base to base 10 notation
- Binary to base 10 / Base 10 to binary
- Hex to binary / binary to Hex
Memory concepts and pointers
- Pointer syntax
- Arrays as pointers
- Dereferencing / address of
- pass by reference vs. pass by value
- reference variables
Structs
- Defining / declaring structures
- pointers to structs
- "->" operator vs. dereferencing
Pointer Arithmetic
- compute the offset of arrays
- Segmentation faults
- passing a pointer by value / reference
Dynamic memory management
- stack vs. heap
- dynamic allocation / deallocation
- "new" operator
- "delete" operator
- Dangling pointers
- Memory leaks
Linked lists
- write a linked list structure for ...
Midterm 2 Practice Questions
- Makefiles
- What is the purpose?
- What goes into compiling?
- Compiling vs linking
- Three main parts of commands (target, dependencies, command)
- What is the syntax of a makefile?
- File IO
- Cin, cout, what are they good for?
- ifstream and ofstream
- How to create a new file?
- How to open a file? How to close?
- How to read from file?
- How to use
getline()
? Difference fromget()
? - How to iterate through entire file
- Arrays
- What are they? Why use them?
- Can you mix different types?
- Index of first element – 0 or 1?
- How do you deal with an array’s size? Ex. in a function call
- How do you create an array?
- How to loop through an array?
- How do you add to an arrary?
- How to read from an array?
- Bounds of an array
- How do you pass in / work with arrays in functions?
- Header files
- What are they? Why do we use them?
- .h files vs .cpp files
- What goes into a .h file? What doesn’t?
- How do you use #include statements to import other files?
- Testing/Debugging
- Stubs – what are they?
- What are preconditions / postconditions?
- Debugging Strategies
- Counting in new Bases
- What is base 2?
- How to convert base 10 to base 2? And the other way around?
- What is octal? What is hexadecimal?
- What is “positional notation”?
- How do you “group the bits” to make converting easier?
- Why is this all useful? Why not just use base ten?
- Pass by value vs reference
- What is the difference? When should we use one over the other?
- Swap value using pass by reference vs value
- What are references?
- What is the
&
character? - How do you pass by reference to a function?
- Can references change the variables they are assigned to?
- Can we use pointers instead of references? What is the difference?
- Pointers
- What are they? Why useful? What do they hold?
- How do we create a pointer?
- How do we point a pointer to a different variable?
- What is the
*
operator? What does it do? Why do we use it? - How are pointers and arrays linked?
- What is pointer arithmetic?
- Structures
- What are they? Why do we use them?
- What are some examples?
- How do we access member variables?
- Structs inside structs
- How to access member vars of structs inside structs
- Linked lists
- what does the structure look like
- inserting a new node to the empty list
- inserting a new node to the beginning/end of the list
- iterating through a list
Good Luck!