CSCI 240 - Possible Questions for Quiz 1

  1. (2 points) Most lines in a C++ program end with a

    1. : (colon )
    2. ; (semi-colon)
    3. } (closing brace)
    4. ) (closing parenthesis)
  2. (2 points) main() marks the beginning of a C++ program. What C++ reserved word precedes it?

    1. #include
    2. using
    3. void
    4. a }
    5. int
  3. (2 points) What is the correct way to declare an integer variable named "score"?

    1. int score
    2. int score;
    3. score: integer;
    4. integer score;
    5. none of the above
  4. (2 points) Given the following declaration:

  5. double x;

    What is the value of x?

  6. (2 points) According to the lecture notes, the two main conceptual components of a program are _____ and _____.

  7. (2 points) Given the following:

  8.   double price = 30.00;
      double tax   = 1.80;
      double sum;
    
      sum = price + tax;

    Explain in detail what the last line does in terms of variables, calculations, and assignment of values.

  9. (2 points) When you write an illegal C++ statement and try to compile and run the program, you will get a

    1. compile error
    2. run-time error
    3. logic error
    4. machine crash
    5. headache
  10. (2 points) What is the value (in C++) of the expression 4 / 2 * 2?

  11. (2 points) What is the value (in C++) of the expression 3/2?

  12. (2 points) Which data type has the largest range?

    1. int
    2. float
    3. double
    4. it depends on the input value
  13. (2 points) About how many decimal places of accuracy does a float have?

    1. 31
    2. 12
    3. 6
    4. 4
  14. (2 points) Modify (rewrite) the following instruction so that the subtraction is evaluated first:

  15. i = a * b / c - d;