CISC-2000-E01 Homework

  1. Thursday, January 16, 2025. Read the course syllabus. Make sure you can log into your account on the Fedora Linux server storm.cis.fordham.edu. Write your secret password on a piece of paper. If you forgot your secret password, submit this form to reset your secret password. Nothing to hand in this week.

    Compare binary.C, which outputs an integer as 32 bits, with hexadecimal.C, which outputs an integer as 8 hex digits. Each hex digit is an abbreviation for a series of four bits. (A series of four bits is called a nibble.) Can you compile and run these two C++ programs in your home directory on storm.cis.fordham.edu?

    Do you understand why the first for loop in loop.C has to perform an invisible multiplication and addition each time you evaluate the expression a[i]? Do you understand how the second for loop avoids this hidden arithmetic?

    Play with the Linux commands. If you put a file in the public_html subdirectory of your home directory on storm.cis.fordham.edu, see if it shows up here. (You may have to refresh this page in your browser.)

  2. Thursday, January 23, 2025. Make sure you can imitate the series of additions I made to bintodec1.C (in bintodec2.C, bintodec3.C, bintodec4.C) to catch the invalid_argument and out_of_range exceptions (and any other exceptions) that might be thrown by the function stoi.

    Admire how sdg5 generated the hexadecimal digits from right to left, and then loaded them into the array result starting at the end of the array and working forward, in his program hexadecimal.C. Compare to this hexadecimal.C.

    Note the similarities between the following programs:

    1. rocket.C looped through an array, and used a pointer (p) to access four consecutive elements of the array (p[0], p[1], p[2], p[3]) during each iteration of the loop. (Does rocket.C run smoothly on your Apple Macintosh or Windows PC? Are you really serious about animating the recursive maze.C program we ran last semester?)
    2. movingaverage.C looped through an array, and used a pointer (p) to access five consecutive elements of the array (p[-2], p[-1], p[0], p[1], p[2]) during each iteration of the loop.
    3. bubblesortintptr.C looped through an array, and used a pointer (q) to access two consecutive elements of the array (q[0], q[1]) during each iteration of the loop.

    The program passstruct.C began with the blueprint for a new type of structure (called a month). It created a variable named j of this type, and passed the address of this variable to a function named f. The function received this address as a pointer named p, and used the pointer to access the two fields inside of j. The blueprint for month had to be written up above the main function, to make it possible to mention the word month in both of the functions main and f.

    Imitating passstruct.C, write a C++ program that has a blueprint for an interesting type of structure containing a few fields. Then create a variable of this type in the main function, and pass the address of the variable down to another function. The other function will receive the address as a pointer named p and will use the pointer to access the fields inside of the structure. Have the function do something interesting with the structire, not merely outputting the fields of the structure. Name your program structure.C, and put it in the public_html subdirectory of your home directory on storm.cis.fordham.edu by 6:00 p.m. EST on Wednesday, January 29, 2025.

    For more inspiration, look at struct.C. It creates a structure named tomorrow, and passes the address of tomorrow down to the one-argument next function, which does an elaborate computation to change the three fields inside of tomorrow to the following day’s date. Good luck.

  3. Thursday, January 30, 2025. The class date in obj1.C already has the following two non-const member functions:
    	void next(int n); //Go n days into the future.
    	void next();      //Go 1 day into the future.
    
    Add two more non-const member functions
    	void prev(int n); //Go n days into the past.
    	void prev();      //Go 1 day into the past.
    
    that will make the object to which they belong move into the past.

    Test your new functions by making a date object that contains March 1, 2025. Make the object go 1 day into the past and verify that it changes into February 28, 2025. Put this program into a file named prev.C in the public_html subdirectory of your home directory on storm.cis.fordham.edu by Wednesday, February 5, 2025 at 6:00 pm EST.

    Also by next Wednesday, make a C++ program named interesting.C in your public_html that creates a class, and creates one or more objects of that class, and calls one or more member functions of these objects to do something interesting. A simple but spiritless possibility would be to create a class time containing three data members named hour, minute, second, very similar to the class date in obj1.C.

    An experiment you could try: what is the biggest number of integers you can say you want to store on storm.cis.fordham.edu in the program new3.C without throwing an exception? Is it always the same number?

    The Rose Hill tutoring room, John Mulcahy Hall room 310, is open 11:30–5:15 M–F (only until 4:00 pm on Monday until they find coverage).

  4. Thursday, February 6, 2025.
  5. Thursday, February 13, 2025.
  6. Thursday, February 20, 2025.
  7. Thursday, February 27, 2025.
  8. Thursday, March 6, 2025.
  9. Thursday, March 13, 2025.
  10. Thursday, March 27, 2025.
  11. Thursday, April 3, 2025.
  12. Thursday, April 10, 2025.
  13. Thursday, April 24, 2025.
  14. Thursday, May 1, 2025.