Midterm 1 sol

Midterm 1 sol - Last name: _ SID (last 4 digits): _ First...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Last name: ________________________ First name: ___________________________ SID (last 4 digits): __________ login id: _______________ CS 010 – Intro to Computer Science I Spring - 2008 Mid-term exam -- Friday 5/2 SOLUTION total 100 points Time: 50 mins. You may have on your desks ONLY this exam, your personalized multiple choice answer sheet, a writing implement and an eraser, and your student ID. You may use a separate sheet(s) of scratch paper. Make good use of them – don’t write your answers in the assigned space until you are sure of them! WRITE CLEARLY IN THE SPACE PROVIDED. WARNING !!!: POINTS WILL HANDWRITING!!! Section I (questions 1 to 20) is to be answered on your multiple choice answer sheet; Section Hand both in together. You will be required to show your student ID when you hand in your exam. Be sure to read each problem carefully and follow the directions exactly. Section I 60 Section II Q.1 20 Section II Q.2 20 TOTAL 100
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Section I: Multiple choice – 3 points each 1. You are writing an inventory program, and need a variable to hold the number of cans in a box, which is 48 for the type of boxes your store currently handles. All of the following options are syntactically correct, but only one is in good style : which is it? a. const int N = 48; b. int cans_per_box = 48; c. int n = 48; d. int N = 48; e. const int CANS_PER_BOX = 48; f. const int cans_per_box = 48; 2. Which of the following statements does not have any syntax errors? (Assume int variables n1 , n2 , and n3 have all been correctly declared and initialized as needed). a. cout << n1; << n2; << n3; b. cout << n1, n2, n3; c. cin >> n1, n2, n3; d. cin >> n1 >> n2 >> n3; e. b) and c) f. none: all of them are syntactically correct 3. What is the exact output of the following code fragment? (Note : the dots on the last line of each answer are simply to help you count spaces) double x = 98.7656789; cout << fixed << setprecision(1); cout << setw(8) << x << endl; cout << setprecision(3); cout << setw(8) << x << endl; a. 98.8 98.766 ............. b. 98.70000 98.76500 ........ c. 98.7 98.765 ........ d. 98.7 98.765 ........ e. 98.8 98.766 ........ f. 98.8 98.766 ........ 4. What is the value of n after the following code executes? int n = 10; n += 4; n = n / 4; n = n % 2; n *= 35; a. 0 b.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

Midterm 1 sol - Last name: _ SID (last 4 digits): _ First...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online