---------------------------------------------------------------- This is a list of some practice questions and problems for this week's quiz. I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of quiz questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). This quiz covers chapter 2. 1) What is a compiler? 2) Which compiler do we use? 3) Demonstrate how to compile a file called main.cpp 4) What is source code? 5) What is the difference between source code and executable code? 6) Convert this pseudocode into C++ code . . . 7) Name several C++ types 8) Which C++ type best fits this situation . . . 9) Demonstrate how to declare a variable of 'this' type in 'this' situation. 10) Demonstrate how to initialize a variable of 'this' type in 'this' situation. 11) Name some C++ keywords. 12) Understand valid and invalid identifiers. 13) What is a literal? 14) What does the ++ operator do? 15) What does the -- operator do? 16) Demonstrate how to make an inline comment 17) Demonstrate how to make a multi-line comment. 18) What is an implicit type cast? 19) What is an explicit type cast? 20) What is the difference between an implicit and explicit type cast? 21) Demonstrate an implicit type cast in code. 22) Demonstrate an explicit type cast in code. ---------------------------------------------------------------- This is a list of some practice questions and problems for this week's quiz. I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of quiz questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). This quiz covers chapter 3. 1) What is a boolean expression? 2) Name several boolean operators 3) Describe short circuit evaluation 4) Give this code . . . (could involve ifs, boolean expressions or short-circuit evaluation), what is the output. 5) Demonstrate proper code for 'this' situation. (Understand how to properly write an if statement and boolean expressions). 6) How is an assignment different from a comparison? How do they look different in code? ---------------------------------------------------------------- This is a list of some practice questions and problems for this week's quiz. I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of quiz questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). This quiz covers chapter 4. 1) Give this code . . . (could involve while loops or for loops), what is the output. 2) Demonstrate proper code for 'this' situation. (Understand how to properly write a for or while loop). 3) Understand how to use boolean expressions in loops. ---------------------------------------------------------------- This is a list of some practice questions and problems for this week's quiz. I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of quiz questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). This quiz covers chapter 5. 1. Give a function definition for . . . 2. Give a function prototype for . . . 3. What is pass-by-value? 4. What is pass-by-reference? 5. When is pass-by-value used? 6. When is pass-by-reference used? 7. Compare and contrast pass-by-value and pass-by-reference? 8. What is the scope of this variable? 9. Show how to call this function. 10. What is a return type? 11. What is a void function? 12. What does the following function do . . . ---------------------------------------------------------------- This is a list of some practice questions and problems for this week's quiz. I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of quiz questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). This quiz covers chapter 6. 1. Demonstrate how to declare an array. 2. What is an array? 3. Demonstrate how to initialize an array. 4. Demonstrate how to set every element of an array to a specific value. 5. Demonstrate how to pass an array to a function. 6. Do arrays act like call by reference? Explain how or why. 7. Demonstrate how to access a specific element of an array. 8. What is the smallest index of an array? 9. What is the largest index of an array? 10. What happens when you "blow array bounds" or access an invalid index of an array? 11. Demonstrate code to solve the following problem with an array . . . 12. What is the output of the following program . . . 13. Demonstrate code to search an array for a specific element. ---------------------------------------------------------------- This is a list of some practice questions and problems for the first quiz. I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of quiz questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). This quiz covers chapter 7 through section 7.8. ------------------------------------------------------------------ Short Answer Questions ------------------------------------------------------------------ 1) Explain how to determine if a C++ program uses dynamic memory. 2) Name at least two major advantages to using dynamic arrays over static arrays. 3) Name a major disadvantage of using dynamic arrays over static arrays. 4) What is the dereferencing operator? 5) What does the dereference operator do? 6) What is the "address of" operator? 7) Convert the following code to use dynamic arrays instead of static arrays. //code for this problem would go here 8) Find the errors in the following code: //code for this problem would go here 9) Demonstrate how to declare a dynamic array (of a specific type) with size input by the user. 10) Why do arrays act like call by reference? 11) Why does every new require a delete? 12) What is the keyword 'new' used for in C++? 13) What is the keyword 'delete' used for in C++? 14) Show a function prototype that passes a dynamic array. 15) What is NULL and how is it used? 16) Demonstrate, in code, how to declare an array with a size determined by the user of the program. ------------------------------------------------------------------ True or False example questions (some of the statements below are true and some are false) ------------------------------------------------------------------ a) Arrays act like call by reference because arrays are dynamic. b) Array names are pointers. c) Static arrays are declared with new. d) Static arrays are declared with a constant size that must be determined at compile time. e) Dynamic memory goes on the heap. f) Dynamic memory does not go on the heap. g) Dynamic memory is destroyed at the end of a function or code block. h) Dynamic memory is not destroyed at the end of a function or code block. ---------------------------------------------------------------- This is a list of some practice questions and problems for this week's quiz. I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of quiz questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). This quiz covers chapter 8. 1) What is a recursive function? 2) What are the base cases of a recursive function? 3) What is the 'winding up' and 'winding down' of a recursive function? 4) How is the stack used in recursive functions? 5) How do you prove that a recursive function is correct? 6) Is recursion faster than iteration? Explain. 7) What is the difference between recursion and iteration. 8) Write code for this recursive function . . . 9) What is the output of the following code . . . 10) What is stack overflow in recursive functions? 11) Can all recursive functions be rewritten iteratively? 12) What is necessary to re-write all recursive functions iteratively? I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). ------------------------------------------------------------------- Chapter 9 ------------------------------------------------------------------ Short Answer Questions ------------------------------------------------------------------ 1) What does the C++ keyword struct do? 2) What does the C++ keyword class do? 3) What is data encapsulation? 4) What is information hiding? 5) Why are classes safer than structs? 6) Demonstrate in code how to make a class. 7) Variables describe an is-a relationship while classes describe a have-a relationship. Example - consider the following two code segments: //segment 1 int a; // a is an integer. //segment 2 class Date { private: //accessors mutators and other functions go here public: int month; int day; int year; }; //Date has-a day month and year. 8) What is an accessor function? 9) What is a mutator function? 10) Why are accessor and mutator functions necessary when using classes and not necessary when using structs? Be sure to describe why to both. 11) Design a class for ... 12) Demonstrate the proper way to define a class. 13) Given a class called Help, demonstrate how to compile the class's implementation file and the main program file called main.cpp. 14) Given a class called Help, what two files should be associated with this class. Describe what these two files do/What is their purpose? 15) What does #include do? 16) What is a preprocessor command? Name two. 17) What is the difference between #ifndef and #define? 18) What is the scope resolution operator? 19) What does the scope resolution operator do? 20) Why is the scope resolution operator necessary? ------------------------------------------------------------------ True or False example questions (some of the statements below are true and some are false) ------------------------------------------------------------------ 1) All data in a struct is public. 2) All data in a struct is private. 3) All data in a class is public. 4) All data in a class is private. 5) Classes are safer than structs. 6) Structs are safer than classes. 7) #include is used to properly protect a header file from multiple inclusions. 8) #ifndef is used to properly protect a header file from multiple inclusions. 9) #include is used to incorporate class header files and function prototypes into a program or implementation file. 10) #endif is needed after a #define. 11) #endif is needed after a #ifndef. 12) #endif is needed after a #include. 13) Classes should be defined in separate files. 14) Classes should be defined in the main program file. ---------------------------------------------------------------- This is a list of some practice questions and problems for this week's quiz. I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of quiz questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). This quiz covers chapter 12 sections. ------------------------------------------------------------------ Short Answer Questions ------------------------------------------------------------------ 1. Explain the difference between fstream and iostream. 2. What is an ifstream? 3. What is an ofstream? 4. How is ifstream different from istream? 5. How is ofstream different from ostream? 6. Can overloaded output and input be used on ofstream and ifstream objects respectively? (The answer here is yes. They can be used on the 'fstream' objects because of a neat class concept called class hierarchies.) 7. What #include directive is necessary for file input and output? 8. Explain why 9. Demonstrate how to open a file called ... for input. 9. Demonstrate how to open a file called ... for output. 10. Name four functions used with ifstream objects and describe what they do. (To answer this question, you must think of these four functions: fail, open, close, >>) 11. Name three functions used with ofstream objects and describe what they do. (To answer this question, you must think of these three functions: open, close and <) 12. Why is file input and output important? 13. Name a real world circumstance where file input and output is used in a program. 14. Demonstrate code to read in a file structured like: . . . 15. Demonstrate code to output to a file structured like: . . . ---------------------------------------------------------------- I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). ------------------------------------------------------------------ Chapter 13 (section 13.8 only) ------------------------------------------------------------------ 1. What is the friend keyword used for in C++? 2. What is overloaded input? 3. What is overloaded output? 4. Demonstrate how to overload input for . . . 5. Demonstrate how to overload output for . . . 6. How does one use cout with a user defined type? 7. How does one use cin with a user defined type? 8. What is the output of the following code . . . ------------------------------------------------------------------ True/False ------------------------------------------------------------------ 1. friend is necessary for mutator functions 2. friend is not necessary for mutator functions 3. friend is necessary for accessor functions 4. friend is not necessary for accessor functions 5. friend is necessary for overloaded input 6. friend is not necessary for overloaded input 7. friend is necessary for overloaded output 8. friend is not necessary for overloaded input