Test 2 CSCI 130
Fall 2013
- Please answer each question fully, carefully and thoughtfully.
- No credit will be given for unreadable answers, please write neatly.
- Answer the questions in any order, but please number each answer.
- Make sure that your name is on your test.
- Named Constants
- [2 point] What is a named constant?
- [2 point] Give the syntax for declaring a named constant.
- [2 point] Provide an example of a declaration of a named constant (code).
- [4 points] Give two reasons to use a named constant in place of a literal value. Justify your answer.
- [2 points] What is the difference between a named constant and a variable?
- Integers
- [2 points] List the different integer types.
- [2 points] State the relationship between the different integer types.
- [2 point] What is integer overflow?
- [3 points] Describe the operation of the C++ increment operator (prefix or postfix, but specify which). Give an example of syntax.
- Floating Point Numbers
- [2 points] What is the difference between a float and a double
- Coercion/Conversion
- [2 point] What is type coercion?
- [2 point] What is type casting?
- [2 point] How is a type cast performed? (Give a code example)
- [4 pints] Why should a programmer perform a type cast?
- [2 pints] What happens when an integer variable is assigned a floating point value?
- Stream Manipulators operators
- [1 point] What include file is necessary for stream manipulation operators?
- [2 points] Describe the operation of setw
- [2 points] Given a code example which will print the value of the variable a at least 15 spaces wide.
- [10 points] Write a program which reads in three integers and prints the average, accurate to two decimal places.