{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2009sol

# 2009sol - APSC 160 SAMPLE MIDTERM EXAMINATION SOLUTIONS...

This preview shows pages 1–4. Sign up to view the full content.

APSC 160: SAMPLE MIDTERM EXAMINATION S OLUTIONS Don't even think about looking at these solutions unless you've put serious effort into coming up with your own solution. Reading a solution that someone else put together is easy and, in itself, will not prepare you for the midterm exam. You need to be able to come up with these solutions on your own! Note: 1) Many people lost marks on Q4A because they did not read the question. If you do not make use of the printStars function, you will lose marks, even though your solution "works". 2) Many people lost marks on Q4B because they did not follow the hint provided. If your solution does not make use of the function written in Q4A, you will lose marks, even though your solution "works". 3) Many people lost marks on Q5B and Q5C because they did not make use of the symbolic constants provided. 4) Many people lost marks on Q5C because they did not make appropriate use of if-else statements and/or their solution incorporated redundant Boolean expressions.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Page 2 of 10 Section 1: Multiple Choice For each of the multiple choice questions below, circle the letter corresponding to the one right answer. [2] Q1A. Consider the following code segment: if( num1 < 2 || num2 > 7 ) printf( "A" ); if( num2 > 9 ) printf( "B" ); else printf( "C" ); What is printed on the screen when this code segment runs assuming that num1 and num2 are variables of type int and that num1 has the value 4 and num2 has the value 8? a) B b) C c) A d) AB e) AC [3] Q1B. Consider the following code segment: int count = 1; int sum = 0; while( count < 6 && sum < 7 ) { sum += count; count++; } printf( "sum = %d, count = %d\n", sum, count ); What is printed on the screen when this code segment runs? 1 mark was awarded if you answered d) rather than a). In that case you got the sum right but the count wrong. There were no marks for choosing b), c) or e).
Page 3 of 10

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern