Sample Test 3

  1. Describe what is meant by an ordinal data type. Give an example of a data type which is ordinal, and an example of one which is not ordinal.

  2. Define a type and create a variable of that type suitable for holding values consisting of the months of the year (January, February, ..., December).

  3. Define a type and create a variable of that type suitable for holding values on the range 10 to 100, inclusive.

  4. The data type Line = STRING[80] has already been defined for a program. Write a short Pascal procedure (call it StarFill) that has as input a variable of type Line. The procedure is to replace all blank spaces in the string with asterisks, and return the altered string. For example, the string
    "I love to ski in   winter"
    would be returned as
    "I*love*to*ski*in***winter"

  5. Write a complete Pascal program that reads in the lines of the text file TestData.txt and prints them to the screen with all blank spaces replaced with asterisks. You may use the procedure StarFill from the previous question without re-writing it here.

  6. Write a procedure (similar to StarFill) called BlankCount that counts the number of blank spaces in a line, but does not alter them. (Hint: the clever student will see how to answer this question by making just a few minor modifications to StarFill.)
  7. Page 383 # 9
  8. Page 383 #10
  9. Rewrite 383 #10 as a procedure, with the count stored in the variable parameter Count.
  10. Page 384 #11 (a little tough, but go for it!)