Test 2 CSCI 130 Fall 2013

  1. Named Constants
    1. [2 point] What is a named constant?
    2. [2 point] Give the syntax for declaring a named constant.
    3. [2 point] Provide an example of a declaration of a named constant (code).
    4. [4 points] Give two reasons to use a named constant in place of a literal value. Justify your answer.
    5. [2 points] What is the difference between a named constant and a variable?
  2. Integers
    1. [2 points] List the different integer types.
    2. [2 points] State the relationship between the different integer types.
    3. [2 point] What is integer overflow?
    4. [3 points] Describe the operation of the C++ increment operator (prefix or postfix, but specify which). Give an example of syntax.
  3. Floating Point Numbers
    1. [2 points] What is the difference between a float and a double
  4. Coercion/Conversion
    1. [2 point] What is type coercion?
    2. [2 point] What is type casting?
    3. [2 point] How is a type cast performed? (Give a code example)
    4. [4 pints] Why should a programmer perform a type cast?
    5. [2 pints] What happens when an integer variable is assigned a floating point value?
  5. Stream Manipulators operators
    1. [1 point] What include file is necessary for stream manipulation operators?
    2. [2 points] Describe the operation of setw
    3. [2 points] Given a code example which will print the value of the variable a at least 15 spaces wide.
  6. [10 points] Write a program which reads in three integers and prints the average, accurate to two decimal places.