Name_______________________ Login___________________SID________

 

CS 010: Introduction to Computer Science I

Quiz 2: 10 minutes

 

  1. Excessive comments add time to the execution of your program.
    1. TRUE
    2. FALSE

 

  1. Which of the following is NOT a valid identifier (i.e. CANNOT be used as a name for a variable).
    1. phone_number
    2. EXTRACREDIT
    3. DOUBLE
    4. my  course
    5. All are invalid

 

  1. The following is an example of what type of error?

int num1;

int num2;

            cout << “Enter two numbers: “;

cin >> num1 >> num1;

 

    1. syntax error
    2. semantic error
    3. logic error
    4. compile-time error
    5. no errors

 

  1. Which statement has a syntax error?
    1. double a = 3.5 + 4;
    2. cout << b + c;
    3. x + y = total;
    4. double Main;
    5. All of the above.

 

  1. What is the output of the following statement?

int num = 26;

cout << “Here it is.” << num << “\nThere it is.”;

 

    1. Here it is.There it is.
    2. Here it is.26nThere it is.
    3. Here it is.26

There it is.

    1. Here it is.

26

There it is.

    1. Here it is.26\nThere it is.

 

  1. Assuming that the user types 14.92 followed by a return, what is the output of the following code:

int num;

cout << “Enter a number:  “;

cin >> num;

cout << num;

 

    1. 0
    2. 14
    3. 14.92
    4. 15
    5. None of the above

 

  1. What is the result of the following code:

int a = 53;

int b = 6;

                        cout << a / b;

 

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

 

  1. We want to translate the following algebraic expression into a C++ arithmetic expression.  Which of the following is the correct form?

a.       1 / c + 1 - a / 1 + b

b.      1 / c + (1 - a / 1 + b)

c.       (1 / c) + (1 - a / 1 + b)

d.      1 / c + (1 - a) / (1 + b)

e.       None of the above

 

  1. What is the result of the following arithmetic expression?  7.0 * 3 % 2
    1. 7.0
    2. 0
    3. 1.0
    4. 10.5
    5. invalid expression

 

  1. All three statements below have the same effects.

a = a + 1;

a = (a+1);

a = 1 + a;

 

    1. TRUE
    2. FALSE