CS102: Exam Review Notes

Structure:

  • 30 minute paper exam

  • 5 minute break

  • Finish exam on Canvas


Disclaimer: This is a guide for studying for the midterm. It is not a guaranteed all-inclusive list of topics and should not be used as your sole source for studying. Review lecture, lecture programs, powerpoints, labs, HackerRanks, notes, and learning material posted on Canvas.
-
Anything covered this semester is fair game.


Midterm 1 Content ( +chmod) – From the Midterm 1 Study Guide

VIM
    
o What is VIM?
    
o Different modes
    
o How to open/save/exit files with VIM
    
o Basic VIM commands

Unix/Linux
    
o What is it?
    
o Commands: ls, cd, etc (plus chmod)
        
§ How to use them (the full command)
        
§ What task each one does
        
§ Able to change permissions for user, group, and world using chmod

Input/Output
    
o C++ syntax for reading in input from the terminal and output using cin/cout
        
§ cin.clear()
        
§ cin.ignore()
            
How to ignore a few characters
            
How to ignore up until a certain character
        
§ Wrapping cin inside an if statement
    
o I/O Manipulators
        
§ What manipulators for cin/cout are persistent? Which ones are not?
        
§ Setw(), setfill(‘0’), left, right, setprecision, fixed, showpoint, scientific, hex,
            
dec

Vectors
    
o Syntax
    
o Methods
    
o Vectors of vectors
        
§ How to declare, how to access
    
o Parallel vectors
    
o Typedef

File Streams
    
o How to write to and from files using ifstream and ofstream

    § Declaring a file stream object
        
§ .open(), is_open(), .close(), .fail()
        
§ Using insertion/extraction operators and manipulators
    
o Error checking

Getline
    
o What are the parameters, how do we use it, what does it return, being able to write
        
an example, etc
    
o Remember that getline can be used for any type of stream – i/o, file, or string
        
streams

Argv/Argc
    
o How to use
    
o Their types
    
o What is stored in each one?
        
§ What is always stored in argv[0]? And what is always stored in non-zero
            
elements of argv?
    
o Given command line examples, show what the values of argc/argv would be in a
            
program
    
o Write main() given argv and argc as arguments to main()
    
o Error checking with argc

String Streams
    
o Similarities and differences between console input/output streams, file streams, and
        
string streams
    
o How to write to strings and extract from strings
    
o Getline() applied to stringstreams

Pass by Reference vs Pass by Value
    
o What do each of these mean?
    
o What is the default with C++?
    
o How can I force a parameter to be pass-by-reference?
    
o Be able to write a signature of a function that has pass by value parameters and pass
        
by reference parameters (last in-lab session had an example of PBR)

Searching algorithms
    
o Linear search
    
o Binary search

Sorting algorithms
    
o Bubble Sort
    
o Selection Sort
    
o Insertion Sort


Number systems
    
o How each of the number systems work (decimal, binary, hex)
    
o Be able to convert from one to another (decimal to binary, hex to binary, etc)
    
o Decimals in binary

Binary Operations
    
o Be able to perform all of these operations: &, |, ^, <<, >>, ~
    
o Which one is a unary operator?
    
o Note: be especially careful with the difference between << and >>

Binary Operation Applications
    
o Using set bit, clear bit, and test bit
    
o Understanding the ASCII table (you do not need to memorize the table, but
        
understand that each character has a numeric value)

2s Complement
    
o Negative binary numbers

Pointers (see pointers.cpp, Pointers powerpoint, and Supplemental Pointer Reading)
    
o How to declare a pointer
    
o How to set a pointer
    
o How to dereference a pointer
    
o How to access data that a pointer points to
    
o How to create a new dynamic variable or object of a specified type and return a
        
pointer to it using the new keyword
    
o How to destroy a dynamic variable using delete
    
o Be able to read code and follow what each variable has stored in memory at which
        
address (i.e. like the problems we did on paper in class, drawing boxes to represent
        
what is stored at each address)

Pointer Arithmetic
    
o Know the sizes of the following data types (see your notes in class when we
        
handwrote this table for the answers). Write the sizes in terms of bytes. You will
        
NOT need to know Values Range for the exam, but it will be helpful to know for job
        
interviews.

Data     Type     Size     Values     Range
Int
Char
Double --------------------------------
Float --------------------------------
    
o How many bits are in one byte?