CS 102 Final Study Guide PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document is a study guide for a CS 102 final exam. It covers topics from midterms 1 and 2 and includes detailed information, explanations, and syntax examples for concepts such as VIM, Unix/Linux commands, input/output, vectors, file streams, and more.
Full Transcript
CS 102 Final Study Guide Disclaimer: This is a guide for studying for the final. 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, labs, notes, and learning material posted on Canvas. Midterm 1 Content ( +c...
CS 102 Final Study Guide Disclaimer: This is a guide for studying for the final. 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, labs, notes, and learning material posted on Canvas. Midterm 1 Content ( +chmod) – From the Midterm 1 Study Guide VIM o What is VIM? o Different modes o How to open a file with VIM on command line o How to enter/exit insert mode o How to save and exit VIM Unix/Linux o What is it? o Commands: ls, cd, mkdir, rm, cp, ssh, scp, chmod § How to use them (the full command) § What task each one does § What the string for permissions stands for when you ls -l § Able to change permissions for user, group, and world using chmod for files and directories § What number system you use with chmod (octal). Input/Output o C++ syntax for reading in input from the terminal and output using cin/cout § What to #include § cin.clear() – what does this do? How does it work? § cin.ignore() – what does this do? How does it work? § Wrapping cin inside an if statement – what does this do? How does it work? o Printf § Know the type specifiers (%f, %d, etc), how to set precision to X amount of decimal places, how to set field width, how to left and right justify o I/O Manipulators § What to #include § What manipulators for cin/cout are persistent? Which ones are not? § Setw(), setfill(‘0’), left, right, setprecision, fixed, showpoint, scientific, hex, dec Vectors o What are vectors? What is it similar to in Java? o Syntax for declaring vectors o Syntax for accessing elements of vectors and assigning elements o.push_back(), size(), clear(), resize() o What to #include o Vectors of vectors § How to declare, how to access File Streams o What are 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 What to #include o Error checking o Getline Argv/Argc o What is argv/argc used for? o What does each stand for? o What are the types of each one? o What is stored in each one? § What is always stored in argv? And what is always stored in non-zero elements of argv? o Why must we sometimes use string streams along with argv/argc? o Given command line examples, show the value of argc/argv 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 What to #include o How to write to strings and extract from strings § Declaring an istringstream and ostringstream object § Using insertion/extraction operators and manipulators §.str() Midterm 2 Content – From the Midterm 2 Study Guide 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) 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 > 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) New Content Since Midterm 2 Pass-by-Value and Pass-by-Reference (see Functions powerpoint, passByValue.cpp and passByReference.cpp, and Supplemental Pointer Reading Section 2. Reference Variables) o What is the difference in syntax when we pass a value by reference in a function definition? How do we call the function with arguments in main? o When is a copy made of function arguments? o How are arrays automatically passed in C++? How are other data types automatically passed in C++? 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 When to set a pointer to NULL o Be able to recognize and/or match definitions of a seg fault, dangling pointer, and memory leak (see pointers.cpp for examples of all of the bullet points above) 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? o Be able to add a number to a pointer and use its data size to figure out the answer. We did practice problems in class, and the pointers powerpoint also has review. Recursion o What is the definition of recursion? o Be able to recognize a recursive function if given a function definition o What are the three parts of a recursive function? (see recusion.cpp notes)