Test I, CSCI 230, Fall 2020


  1. Algorithms
    1. [2 points] What is the purpose of writing an algorithm in the design phase?
    2. [3 points] When writing an algorithm in the design phase, why is it inappropriate to write the algorithm in c++ code?
  2. Integer Data Types
    1. [3 points] List the different integer data types in c++?
    2. [2 points] What is the relationship between the integer data types in c++?
    3. [1 point] What is the difference between a signed and an unsigned integer type?
  3. Strings
    1. [1 point] What is the domain of a string?
    2. [3 points] List and describe three operations on a c++ style string.
  4. [5 points] Write a function which takes a string as a parameter and returns the string as all upper case characters. The function prototype is provided.
  5. [2 points] What does the c++ typedef statement do?
  6. Enumerator Types
    1. [2 points] What is the purpose of enumerator types?
    2. [4 points] Why are enumerator types superior to strings when either is applicable? State and justify at least two arguments.
    3. [2 points] Provide code to declare an enumerator type that represents the days of the week.
    4. [2 points] Describe a common operation that can not be performed directly on an enumerator type.
  7. Structures
    1. [2 points] Describe two properties of the datatype struct.
    2. [2 points] What is the purpose of the following code. How much memory is allocated due to this code?
      struct MyDataT {
          string word;
          int count;
      }; 
    3. [2 points] Using the structure defined in the previous step, provide code which will
      • declare an instance of the structure
      • set the word field of the structure to be "hello"
      • set the count field of the structure to be 1
    4. [2 points] Name two different types operations which can not be performed on structures.
  8. [5 points] The file numbers.txt contains 10 integers. Write a function which finds the maximum and minimum of the values in this file. The function should take the file name, a string and two integer reference parameters max and min. The prototype for the function is provided.
  9. [5 points] Assume afile.txt exists and contains only integer data. The programmer wishes to count the number of integers in the file. Describe all errors contained in the following code segment. You may assume that all code before and after this code is correct and that all required files have been included.

Submission Instructions