1. (15 points) Write a Unix command to accomplish each of the following:

  1. Create a directory named project_dir under the current directory.
  2. Make the directory named project_dir the current directory.
  3. List the names and sizes of all the files in the current directory.
  4. Delete all files in the current directory that have the letter 'a' anywhere in their names.
  5. Copy a file named some_file from Dr. Vickery's CS-200 directory into the current directory.
  6. Use the compiler driver to translate plist.cc and main.cc into an executable file named plist.
  7. Get rid of the files that don't belong in a project directory when you submit an assignment.
  8. Create a tar file for submitting an assignment.

2. (10 points) Write a complete C++ program that prompts the user to enter three numbers of type float, reads the numbers, and displays the value of the smallest.

3. (15 points) Write C++ code that creates a variable named stuff which can hold an integer, a long, a pointer to an integer, and a pointer to a long. Write a statement that prints the value of the long. Assume an integer is four bytes and all the other data types are eight bytes long. Ignoring any extra bytes the compiler might insert to align data items on address boundaries, how big is stuff?

4. (15 points). Write C++ statements to declare a pointer to char named ptrToChar and a char array named charArray that is just large enough to hold the string "this string". Write an assignment statement that puts the address of the first byte of charArray into ptrToChar. How big are ptrToChar and charArray, in bytes?

5. (15 points) Write a template function that takes three arguments, all of the same data type, and which returns their average as a double.

6. (10 points) Explain how C++ can let you write two different functions with the same names. How can the compiler tell which function you want to call when it finds a function reference in your code?

7. (20 points) Write a complete C++ program that allows a user to enter words into an array of character strings. The program prompts for an array position, reads the position, exits if the position is negative, issues an error message if the position is greater than the size of the array, prompts the user for a word, reads the word, displays the word at the array position if the word is "show," and copies the word into the array at the proper position otherwise. The program runs until the user enters a negative position number. Assume the user makes no typing mistakes.


Christopher Vickery
Queens College of CUNY