Name_______________________ Login___________________SID________

 

CS 010: Introduction to Computer Science I

Quiz 3: 10 minutes

 

  1. What is the output of the following code?

int a = 28;

int b = 19;

int c = 3;

int d = 2;

cout << a % b % c / d;

 

    1. 1.5
    2. 1
    3. 0.25
    4. 0
    5. None of the above

 

  1. What is the output of the following code?

int a = 9;

int b = 6;

double c = 2.2;

cout << 4.4 + c * (a / b);

 

    1. 7.7
    2. 6.6
    3. 9.9
    4. 11
    5. None of the above

 

  1. What is the output of the following code?

string fun = “I love C++”;

cout << fun.length();

 

    1. 1
    2. 9
    3. 10
    4. 8
    5. None of the above

 

  1. Given that    str = “Snoozing under a tree”,  what would be the result of the following statement

cout << str.substr(1, 1) + str.substr(9, 2);

 

    1. Sun
    2. nun
    3. nnd
    4. S u
    5. None of the above

 

  1. What does the following output produce?  (Note: a dash is representing a space.)

double x = 1.0;

double y = 777.777;

cout << fixed << setprecision(2) << setw(8);

cout << x << “\n”;

cout << y << “\n”;

 

a.     ----1.00

777.78

b.     -------1

777.78

c.     ----1.00

--777.78

d.     ----1.00

777.777

e.     None of the above

 

  1. The Point type is built into the C++ language.
    1. TRUE
    2. FALSE

 

  1. What is the value of c.get_center and c.get_radius after the following code?

            Circle c(Point(-1, 2), 4);

            c.move(3, 2);

 

    1.  (-4, 4) and 4
    2. (4, 0) and 2
    3. (2, 0) and 4
    4. (2, 4) and 4
    5. None of the above

 

  1. The following code has what kind of error?

Time morning(7, 0, 0);

cout << Time.get_hours();

 

    1. logic
    2. syntax
    3. run-time
    4. operational
    5. No errors

 

  1. The following code has an error on which line?

Line 1               Point p(0,0);

Line 2               Point q(3,3);

Line 3               Line stick(p, q);

                        Line 4               cwin << get_start();

 

    1. Line 1
    2. Line 2
    3. Line 3
    4. Line 4
    5. No errors
  1. What type of character does the following code display?

Point p(2,4);

Line s(p, Point(4, 4);

cwin << s;

p.move(0,2);

Point q = p;

q.move(0, -4);

cwin << Line(p, q);

p.move(2, 0);

q.move(2, 0);

cwin << Line(p, q);

 

a.       U

b.       T

c.       H

d.       E

e.       None of the above