Review for Final Exam

Final to be held 3:30 pm Friday 12/8 in 101 Churchill

COM 1100 Foundations of Computer Science

Fall 2000 -- Professor Futrelle
College of Computer Science, Northeastern U., Boston, MA

Final posting 12/5/00. Original posted 11/30/2000.

The overall structure of the Final Exam is a collection of 25 to 30 short-answer questions. The large number will make sure that all the important material is covered and will assure that we have a good understanding of what you have finally learned in the course. So the final will be an important test for you. If you've been keeping up all along, there will be no surprises on the Final. Because of the large number of questions, you grade will not be hurt much if you draw a blank on a few of them.

Each chapter in the book ends with a "Summary of New C++ Constructs" which you should look at, along with the material in the chapter proper. Each chapter also has a section, "Common Programming Errors", which may help you from making the same mistakes on the Final.

Chapter 2, the Overview of C++, will probably make a lot more sense to you now, and you can profit from reading it. It includes the important material about evaluation trees, summarized in Fig. 2.14. For the Final, you should know essentially all the material covered in Chapter 2. In what follows, I'll point out some more specific material from various chapters that you should also know.

In Chap. 3, you should be familiar with the math library functions in Table 3.1. Study the table carefully but you do not need to memorize the details, just understand them. You might want to write a simple program that uses these functions to help you understand how they work.

Of course you need to understand the difference between a function declaration (or prototype) and a definition. Functions with input arguments and the correspondence of arguments and parameter lists is important. Know the difference between arguments and parameter lists. Understand how the return type of a function is specified and used.

Scope of names is not a simple concept, but it is important. Global constants are just one example. Given a question about string functions, Table 3.3, you should know enough about the basic functions to answer it.

We have not worked with header files you define yourself, but the distinction is an easy one to learn, pg. 153., so learn it.

Chapter 4, on control structures and if and switch in particular, covers them but also explains the logical expressions they use, in Sec. 4.2. Remember the difference between "=" and "==" completely different concepts! You don't have to memorize the entire operator precedence table, 4.6, but the more of it you know, the better.

You must know the exact syntax of the if and switch statements, including just how to use else and how to place the case and ':' and break portions of switch. I will not ask you about compound if structures such as if ... else if .... else if ... else. Be careful to use curly braces, {....}, to execute compound statements in an if ... else statement. And watch those stray semicolons!

Chapter 5 has the all-important repetition and loop statements, for and while. We've certainly discussed these a fair amount and you have had opportunities to use them in your labs. But again, watch for that stray semicolon, e.g., the nonsensical while(...); statement, with no body, no statements that are executed under control of the while. Know what is meant by a (logical) "flag", pg. 259. Sentinels, covered at the beginning of Sec. 5.5, will not be on the Final. They'll be useful later in the design of high-performance algorithms, e.g., in COM1201.

Two useful shorthands that are quite common are described in this chapter and you should know them. The first is compound assignment operators, pg.237. Write yourself out some examples so you're sure how they work. And remember, they work with array elements also. The second shorthand is found in the increment and decrement operators, ++ and --, pgs. 241-2.

Chapter 6 has one important section, Sec. 6.1 on reference parameters. The '&' appears in function declarations and definitions, e.g., void foo(int&); but not when the function is called. By then, the compiler knows that a reference parameter is being used. You should be alert for questions in which a reference parameter is not used so that changes to the variable within a function have no effect outside the function (where it was called from). Additional information on reference parameters is contained in Sec. 6.2, but 6.1 has the basics.

Chapter 8 deals with streams and files, input and output (I/O). As I said in class, some of the details of I/O are so messy that I would not ask about them in a test. But you should know the basics, which are how cout and cin deal with basic types such as integers, floats, characters and strings. get() and getline() read in all characters, including blanks. The '>>' input operator, reading integers for example, will skip all blanks (and tabs and newlines) between integers in the input stream.

You should know the basic file stream functions, such as open() and close() and fail(), which must be used with dot notation, e.g., ins.open("myfile.txt"). Remember that the input functions can be used in conditions to signal the absence of any more input, e.g., while(cin.get(next)) on page 393.

The important sections are 8.1, 8.2 and 8.4. In Sec. 8.5 you need only know the most basic manipulators such as setw() and setprecision(). Of course you know endl. Happily, Chap. 8 is quite short.

Chapter 9 has our last topic, arrays. Arrays are ZERO-BASED, so int arr[]={2,9,7} has 3 elements with index values 0, 1 and 2. Array elements, e.g., arr[1] behave just like variables: they have values, can be assigned to, can be used with increment/decrement operators (++, --) and compound assignment statements, e.g., +=, *=, etc. Even this works: arr[arr[0]] (it has the value 7). If you want to pass a single array element to a function, the parameter list is no different that it would be for an ordinary value or reference parameter, e.g., on pg. 442.

The rules are a little different when dealing with entire arrays, when defining and using functions with array arguments, Sec. 9.3. There you can see a declaration (prototype) on pg. 446 with parameters such as float[]. (We're ignoring const in my section this quarter.) In a definition, such as on pg. 444, parameters appear in the form float a[]. Simplest of all is when you give a function an actual parameter in a function call. For our array above, you'd just use it in the form someFun(arr), no "[]" at all, bottom of pg. 443.

That's all -- and that's enough! Good luck. -- RPF