This website is preserved for historical and scholarly reference and is no longer actively maintained.

Midterm Exam

October 17, 1997

#1. What value will be assigned to the variable m by each of the following ( 2 pts. each ).

#2. Draw the result (in the style of the text) of executing the following code. You should draw boxes for the variables p and q, draw hexagons for objects, and show pointers from p and q. ( 4 pts. )

#3. Draw the result (in the style of the text) of executing the following code. You should draw boxes for the variables p and q, draw hexagons for objects, and show pointers from p and q. ( 4 pts. )

#4. Draw a table giving all 4 possible truth assignments to boolean variables A and B. Fill in table values for A && B, A || B, and ! A. ( 10 pts. )

#5. Draw a flowchart (graphic illustration) for the following code segment (10 pts.)

#6. Show the output of execution of the following code segment. (6 pts.)

#7. Rewrite the code for problem #6 using two for-loops instead of while statements. (4 pts.)

#8. Draw a flowchart (graphic illustration) for the following code segment. (10 pts.)

#9. 5! = __________ (Give the answer an a single integer -- 5 pts.)

#10. List the first 5 prime numbers ( 5 pts. )

#11. Select words from this list to identify with phrases below (10 pts.)

#12 Complete the function below. The function finds and returns the smallest of four integers. Doi not write any extra code other than the code required to complete the assigned task. After you have written your code "walk through" your code to be sure it works. (10 pts.)

#13. Complete the function below. The function finds and returns the nth power of x. DO NOT USE THE BUILT-IN Math.Pow function. Compute this yourself (10 pts.).



Return to Eleanor Hare's Home Page.

Return to Department of Computer Science Home page.