Test 1 CSCI 130 Summer 2011


  1. Identifiers
    1. (2 points) What is an identifier?
    2. (6 points) Give the rules for constructing an identifier and an example which violates each rule. State how your example violates the rule.
  2. Constants
    1. (2 points) Give the syntax for declaring a named constant.
    2. (2 points) Give an example of how a constant is declared.
    3. (6 points) List the conventions for creating a named constant.
  3. Variables
    1. (2 points) How is a variable different from a constant?
    2. (2 points) Give the syntax for declaring a variable.
  4. Data Types
    1. (2 points) What is a data type?
    2. (3 points) List the basic floating point data types
    3. (2 points) What is the relationship between the floating point data types listed above.
    4. (3 points) Describe the floating point data types.
  5. Variable Initialization
    1. (2 points) What does it mean to initialized a variable?
    2. (2 points) Why is it important that variables be initialized?
    3. (2 points) Show how to initialize a variable when it is declared.
  6. (4 points) Justify why it is better to use the constant SALES_TAX than the floating point literal 0.06 in a program.
  7. (10 points) Write a complete C++ program which will prompt the user for two integers a and b and print a/b as a mixed number. If the numbers are 4 and 3, the output would be 4/3 = 1 and 1/3, while the input 6 and 2 will output 6/2 = 3 and 0/2. You may assume that b will not be 0.