Homework for CISC-1600-E01 and CISC-1610-E01

  1. Thursday, August 29, 2024. Bookmark the home page for this course, https://markmeretzky.com/fordham/1600/, on your computer. Read the course syllabus, including the links about attendance and plagiarism. Admire the public_html directory of each student.

    Write down your login name and secret password for our Fedora Linux server storm.cis.fordham.edu in a safe place. If you have already forgotten or lost your password, you can request a new password with this form. Log into storm during the week.

    Practice downloading files from the web into your home directory. For example,

    jsmith@storm:~$ date           (Make sure that storm.cis.fordham.edu can hear you and is responding.)
    jsmith@storm:~$ cal
    
    jsmith@storm:~$ cd             (Go to your own home directory.)
    jsmith@storm:~$ pwd            (Make sure you arrived there.)
    jsmith@storm:~$ ls -l          (See what's in your own home directory.)
    
    jsmith@storm:~$ wget https://markmeretzky.com/fordham/1600/src/dime/dime1.C
    jsmith@storm:~$ ls -l          (Did the new file actually arrive?)
    

    Practice using vi (the “visual editor”) to modify a file. For example,

    jsmith@storm:~$ cd
    jsmith@storm:~$ pwd
    jsmith@storm:~$ ls -l
    
    jsmith@storm:~$ wget https://markmeretzky.com/fordham/1600/src/xanadu.txt
    jsmith@storm:~$ ls -l
    
    jsmith@storm:~$ vi xanadu.txt
    

    Practice using the “compiler” (i.e., translator) c++ to “compile” (i.e., translate) a C++ program into terms that storm.cis.fordham.edu can understand and execute. (The full name of the compiler is /usr/bin/c++.)

    jsmith@storm:~$ cd
    jsmith@storm:~$ pwd
    jsmith@storm:~$ ls -l
    
    jsmith@storm:~$ c++ dime1.C
    jsmith@storm:~$ ls -l           (See if c++ created a new file named "a.out".)
    
    jsmith@storm:~$ ./a.out         (Execute the program and send its output to the screen.)
    jsmith@storm:~$ echo $?         (If you're interested, see the invisible "exit status" number produced by the program.)
    
    jsmith@storm:~$ ./a.out > dime1.txt         (Execute the program and deposit its output into a new file "dime1.txt".)
    jsmith@storm:~$ ls -l           (See if you created the file dime1.txt.)
    

    Practice copying files into your public_html directory so you can see them with a web browser.

    jsmith@storm:~$ cd
    jsmith@storm:~$ pwd
    jsmith@storm:~$ ls -l
    
    jsmith@storm:~$ cp dime1.C public_html
    jsmith@storm:~$ cp dime1.txt public_html
    
    jsmith@storm:~$ cd public_html
    jsmith@storm:~$ pwd
    jsmith@storm:~$ ls -l        (See if the copies are actually there in your public_html directory.)
    

    Then see the files in your public_html directory by pointing your web browser at
    https://storm.cis.fordham.edu/~jsmith/dime1.C
    https://storm.cis.fordham.edu/~jsmith/dime1.txt

    Study the C++ programs dime1.C through dime6.C. Now make two changes to the C++ program flag.C.

    Execute your changed flag.C and deposit its output into a new file named flag.txt. Copy your changed flag.C and its file of output flag.txt into your public_html directory. Next week, our web server should be configured so that you can see these two files by pointing your web browser at
    https://storm.cis.fordham.edu/~jsmith/flag.C
    https://storm.cis.fordham.edu/~jsmith/flag.txt
    Until then, you can see your files here.

    If you have time: I heard three beeps when I executed a C++ program including the following statement while connected to storm.cis.fordham.edu from my Macintosh. Can you hear the beeps? Turn up the volume.

    	std::cout << "\a\a\a\n";       //the ASCII "alarm" character
    

    For the two students who could not log into storm.cis.fordham.edu:

  2. Thursday, September 5, 2024. If storm.cis.fordham.edu is rejecting your password, you can request another password by filling out this form.

    Study the programs we looked at in class today, and download and execute some of them. Try new combinations of data types. For example, could you store input from cin into a double variable the way we stored input into an int variable here? Could you find the maximum (and minimum) values we could store into a double variable the way we found the maximum (and minimum) values we could store into an int variable here? (Expect the maximum double value to be a humongous number around 1.8 × 10308.)

    Why do the possible values for an int go from -2,147,483,648 to +2,147,483,647? I tried to write out the answer here more neatly than I did on the whiteboard in class on September 5.

    Also look at the table of operator precedence and associativity, starting with lines 5 and 6. On September 12, we’ll also look at lines 2, 7, 16. Does C++ have a dismaying number of operators?

    Do you get the same unpredictable garbage each time you execute the following code? Run it three or four times. (“nan” means “not a number”; “inf” means “infinity”.)

    //Remember to compile with c++ -std=c++20 programname.C
    #include <format>     //for format.  Remember the other #include's
    using namespace std;
    
    	int i;      //unpredictable garbage
    	double d;   //unpredictable garbage
    
    	cout << i << "\n";
    	cout << d << "\n";
    	cout << format("{:15}", d) << "\n";
    

    Write a little C++ program that inputs (using cin) one or more values into one or more int or double variables, does some arithmetic with these variables in an expression, and outputs (using cout) the result. Invent something interesting. Some suggestions:

    Copy your C++ program into your public_html directory. For inspiration, see what the other students have done here.

  3. Thursday, September 12, 2024. By now, you should have writen at least one C++ program that receives input from cin and stores the input into a variable, checks to make sure that the input was successful, computes a value (the final answer) by means of an expression, stores that value into another variable, and outputs the value of that other variable. Write a program that does int arithmetic with / % to compute the quotient and remainder resulting from an int division. This quotient and remainder could be dollars and cents, hours and minutes, gallons and quarts, etc.)

    Also play with while and for loops. (I updated the embarrasing, obsolete initialization of the variable in for2.C and beer.C.) Can you store the output of stylesheet1.C into a file (named stylesheet1.html) and see it in your web browser? Could you write a for loop that computes the sum of all the integers from 1 to 100 inclusive? (The sum is 5,050.)

  4. Thursday, September 19, 2024.
  5. Thursday, September 26, 2024.
  6. Thursday, October 3, 2024.
  7. Thursday, October 10, 2024. The midterm exam is on October 10 or 17.
  8. Thursday, October 17, 2024.
  9. Thursday, October 24, 2024.
  10. Thursday, October 31, 2024 (Hallowe’en).
  11. Thursday, November 7, 2024.
  12. Thursday, November 14, 2024.
  13. Thursday, November 21, 2024. No class on Thanksgiving.
  14. Thursday, December 5, 2024.
  15. Thursday, December 12, 2024. The final exam is on Thursday, December 19, 2024.