Test 1 CSCI 130 Fall 2021


  1. Algorithms
    1. [2 points] To be an algorithm a list of instructions must have two properties. What are these properties?
    2. [2 points] Why should a programmer develop and test an algorithm before beginning to code a solution.
  2. Program construction.
    1. [5 points] Give the code required for nearly all c++ programs.
    2. [1 point each] From the above code, give an example of each of the following program elements.
      • Reserved word
      • Identifier
      • Preprocessor directive
  3. Comments
    1. [4 points] Give two possible uses of comments in a program.
    2. [2 points] Describe the behavior for comments included in /* */.
    3. [2 points] Describe the behavior for comments beginning with //
  4. Identifiers
    1. [2 points] What is an identifier?
    2. [3 points] Give the three syntax rules for declaring an identifier.
    3. [3 points] For each syntax rule you listed above, give an example of an word that violates the rule. Explain how your example violates the rule.
  5. Constants
    1. [3 points] What is a constant?
    2. [2 points] When should a programmer employ a constant?
    3. [3 points] Critique the following declaration.
      const string FIRST_STRING{"Hello World"};
             
    4. [1 point] According to the local convention, where in the program should constants be declared?
  6. Variables
    1. [3 points] What is a variable?
    2. [2 points] Give two conventions for declaring a variable.
    3. [2 points] Declare an integer variable that holds the current hour. Initialize this to be 12.
    4. [1 point] According to the local convention, where in the program should variables be declared?
  7. Compiler
    1. [3 points] What is a compiler?
    2. [2 points] What is a side-effect of a compiler?