Name_______________________ Login___________________SID________

 

CS 010: Introduction to Computer Science I

Quiz 3: 10 minutes

 

  1. setprecision(2) and fixed manipulators in an cout statement will cause all following output of double values to show exactly 2 digits after the decimal place until it is explicitly changed.

a.      TRUE

b.      FALSE

 

  1. setw(8) manipulator in a cout statement will cause all following output of any type to be displayed within 8 spaces until it is explicitly changed.

a.      TRUE

b.      FALSE

 

  1. If the data being output after a setw(8) manipulator needs more than 8 spaces, only the first 8 characters will be output.

a.      TRUE

b.      FALSE

 

  1. Time is a built-in or fundamental type of C++.

a.      TRUE

b.      FALSE

 

  1. Which statement in the following code fragment has an error and which type of error is it?

Time dinner_time = Time(19,30,0);

dinner_time.add_seconds(1800);

cout << dinner_time;

 

    1. The first statement has a syntax error
    2. The first statement has a logic error
    3. The second statement has a syntax error
    4. The third statement has a syntax error
    5. The third statement has a logic error
    6. There are no errors in this code fragment.

 

  1. Which statement(s) in the following code fragment has a syntax error?

Circle c1(Point(4,5), 3.5);

c1.move(-2.5,2);

cwin << c1;

 

    1. The first statement
    2. The second statement
    3. The third statement
    4. The first and second statements
    5. The second and third statements
    6. There are no syntax errors in this code fragment

 

  1. What is the value of start.get_x() and line1.get_start() after the following code fragment?

Point start = Point(3,4);

Point end = Point(4,5);

Line line1 = Line(start, end);

line1.move(1,0);

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

 

  1. Which of the following is not a legal statement?
    1. Time now;
    2. Time now();
    3. Time now(4,0,0);
    4. Time now = Time(4,0,0);
    5. none of the above

 

  1. Which statement has a syntax error, given that c is a properly constructed Circle object, and ln is a properly constructed Line object?
    1. Point p = Point(1,2);
    2. Point p = c.get_center();
    3. Point p = ln.get_start();
    4. Point p = c.move(1,3);
    5. None of the above

 

  1. What output by the following code fragment?

Point p1 = Point(0,0);

Point p2 = p1;

p1.move(-3,3);

p2.move(3,-3);

cwin << Line(p1,p2);

p1.move(0,-6);

p2.move(0,6);

cwin << Line(p1,p2);

 

    1. a square
    2. parallel lines
    3. a shape in the form of an x
    4. a shape in the form of a +
    5. none of the above