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

  1. Create a directory named project_dir in 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' somewhere in their names.
  5. Copy a file named a_nice_file from Dr. Vickery's home directory to the current directory.
  6. Use the compiler driver to translate main.cc and gcd.cc into an executable file named gcd.
  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 their average.

3. (15 points) Write C++ code that creates a variable named uni which can hold an integer, a long, a float, a pointer to an integer, a pointer to a long, or a pointer to a float. 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. How big is uni?

4. (15 points) Write C++ statements to create a variable named a_str that can hold the address of a character and which is initialized with the address of the first character in the constant "hello". Tell how much memory the compiler reserves for the variable and how much it reserves for the constant. Draw a diagram to show the relationship between the variable and the constant.

5. (15 points) Write a function that computes the maximum of three values. Use a template so the function will work with any data type so long as all three values are of the same data type. Efficiency of your algorithm counts.

6. (10 points) What is the "mangled" name that g++ uses for this function:
int someFunc(int, char *, float, int, int);

7. (20 points) Write a complete C++ program that prompts the user to type a word. If the word is "exit" the program terminates. If the word is "show" the program displays everything the user has entered so far, and if the word is anything else, the program prompts the user for a number, reads the number, and then asks the user for another word.. All the words (except "show") and their numbers are kept in an array of appropriate data structures. If the array fills up, the program displays all the entries in the array, and terminates. Assume the users never type more than 31 characters in a word and never type blanks inside a word.


Christopher Vickery
Queens College of CUNY