COM 1100 Foundations of Computer Science

ANSWERS FOR QUIZ #1 -- given Tuesday, Sept 26th

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

 

Print your name here: ____[a few of you forgot to put your name here]______________

Your ID number                    
 digits    1  2  3  4  5  6  7 your digit  9

If your digit is:

    0 or 3 answer question 4
    1 or 9 answer question 3
    2 or 6 answer question 5
    4 or 7 answer question 2
    5 or 8 answer question 1

If you feel that you cannot answer the question that you're supposed to, you may choose to answer one of the other four questions. Your maximum possible score on the quiz would then be 75 points instead of 100.

WE COULDN'T TELL WHETHER YOU DIDN'T UNDERSTAND WHAT QUESTION TO CHOOSE OR DELIBERATELY CHOSE ANOTHER. ANYONE NOT FOLLOWING THE DIRECTIONS ABOVE GOT A MAXIMUM OF 75 POINTS.

SOME MISSPELLINGS WERE NOTICED ON THE EXAM -- CORRECT SPELLINGS ARE: "continuous", "programmers" and "erased".

Question 1 --

1a. What is the standard name (acronym) for volatile computer memory? What does the acronym stand for?

ANSWER: RAM = random access memory. The word "volatile" is applied to liquids that evaporate easily or people or situations that change rapidly. (Check you dictionary.) So volatile is the opposite of permanent. RAM loses its contents when power is removed from it (turning off a computer).

1b. In the line below, one character is out of place. Rewrite the line correctly.

    <#include iostream>

ANSWER:     #include <iostream>
Friedman, page 29.

Question 2 --

2a. What is wrong with the following main program skeleton (code details are omitted)? Rewrite it correctly.

   int main {}
         (
           ....
         )  

ANSWER: See Friedman, page 29. The curly braces and parentheses were incorrectly exchanged. The form should be:

   int main ()
         {
           ....
         }  

2b. How is it possible for two traces on a printed circuit board to cross without interfering with one another? Draw a diagram to explain your answer if needed.

ANSWER: A printed circuit board (PCB) typically has two surfaces and traces ("wires") can run in one direction on one side and another on the other, so when they "cross" they're on separate sides and don't interfere. Here's a link to some notes about software to design such boards.

Question 3 --

3a. There is one punctuation error in the following line. Rewrite the line correctly.

    float miles; kms;

ANSWER: If "miles" and "kms" are both to be floating point variable names they must be separated by a comma (Friedman page 29):

    float miles, kms;

3b. What program converts between object code and source code: the linker, the compiler, or the loader? Which type of code is the input and which is the output of the processing?

ANSWER: The compiler takes source code (text) as input and produces object code (binary) as output. (Friedman, page 21)

Question 4 --

4a. Write out the two phrases represented by the acronyms "CPU" and "ROM".

ANSWER: CPU = central processing unit and ROM = read-only memory (permanent, non-volatile) (Friedman pages 10 and 8, respectively).

4b. List all the integer values representable by three bits, writing each in both binary and decimal form. What is the relation between the number of values, the number of bits, and the a power of 2?

ANSWER:


000 binary = 0 decimal
001 binary = 1 decimal
010 binary = 2 decimal
011 binary = 3 decimal
100 binary = 4 decimal
101 binary = 5 decimal
110 binary = 6 decimal
111 binary = 7 decimal

The number of values represented by n bits is 2n, so 23 = 8 values for 3 bits. Another way to see this is that the number of combinations of 1s and 0s is 2 for the first bit times 2 for the second bit times 2 for the third bit = 2*2*2 = 23.

Question 5 --

5a. There are two errors in the following assignment statement. Write out the correct form of the statement.

    kms == KM_PER_MILE x miles;

ANSWER: The correct form is on page 29 of Friedman:

    kms = KM_PER_MILE * miles;

5b. State two of the problems that make program maintenance difficult.

ANSWER: One of the major problems is the lack of proper comments and related documentation, so that people working on the programs later (even the same people!) cannot readily understand what was done. A second problem is poor choices of names for variables and functions that don't clearly express what they are for.