Friday, December 11, 2009

Answers to Midterm 1

available here.

Thursday, December 10, 2009

Answers to Midterm 2

are here.

Answers to midterm 1 to come a bit later...

The two midterms from this semester -- answers to follow

Midterm 1

and Midterm 2

Answers to come

Tuesday, December 8, 2009

Review of second of two sample midterms

Midterm 2, the DOC file

1) since it *terminates* when either is true, it is Until, rather than While. So we need to negate. So it is the opposite of the two conditions, coupled with an And. Therefore, D.

2) C

3) It reads it at the bottom of the loop, and checks it
at the top, before using it. Therefore, the letter "q" would be read but not used. That tells us either B or C. Now, each time it appends the letter at the *beginning* of what was read, rather than at the end. so it is nop reversed, which is pon. Thus, B.

4) This accumulates all the values in the file, finding its sum. Thus, B.

5) Num starts out at 7, but is incremented before it is ever printed. We can cross out anything involving a 7. Num is greater than 6, so the loop will not repeat. Afterwards, we print again. Therefore, 8 and 8, which is D.

6) We fill the array with those values. We start at the end, and skip one each time. Britain must be first, so either B or D. And since we skip, Beetoven cannot appear, so it must be D.

7) C

8) B

9) C, because H, B, D, B is not purely ascending or descending.

10) A, since there are 3 elements.

Part II
a) since it is not modified by the second loop, it would be whatever 70 * 70 is.

b) since we are copying the value from a(i+13) into that slot, and initially, a(11+13) was set from the first loop, it should have (11+13)^2, whatever that is.

Part III
Answer: The first two loops just fill the arrays A and B. The third loop increments a counter variable whenever the two arrays have the same element in the same position. The ones which are aligned are 3, 5, 3, I think. So c is 3. What will be output? I think 3.

Review of first of two sample midterm 2s

watch here for more.

http://venus.cs.qc.edu/~jlevy/cs80/docs/sample-Test.pdf

multiple choice answers -- for clarification, email me.
1) D
2) A
3) C, because we negate the condition
4) C
5) C
6) C
7) C
8) D
9) here, num(k) is exactly the same as k.
therefore, it is 10^1 + 10^2 + 10^3 + 10^4
which is 11110
therefore, B
10) This is just asking for phrase(1), not for the
entirety of phrase. Each time, we search for the
next space, and take the substring from the *beginning*
up to that space. So, it should be the first two words,
every path.
Therefore, B

Programming:
1)
' We need to make an array to store those:
Dim a(999) as Integer
' then read those numbers in
for each x in a
x = InputBox("gimme the next number")
next
' and then start from the *end* of the array to print
for i = 999 To 0
Debug.Print(a(i))
next

2) ' in the last for loop, replace with
for i = 999 To 0
   if a(i) mod 2 = 0 then
Debug.Print(a(i))
   end if
next

Watch this space...

I hope to put up a review of the two sample second midterms...

Wednesday, December 2, 2009