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.
ssh jsmith@storm.cis.fordham.edu
jsmith
stands for your Fordham ID.
Terminal
application
and type the following “secure shell” command:
ssh jsmith@storm.cis.fordham.edu
jsmith
stands for your Fordham ID.
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
.
using
statement so you don’t have to say std::
10 times.
dime6.C
produced all three of its lines of output with a single statement.
Since there is only a single statement,
there will now be only a single semicolon (;
).
(Of course, the
return
statement will still have its own semicolon.)
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
:
storm.cis.fordham.edu
account for
dg51@fordham.edu
,
and emailed him his insane temporary four-word password.
ac239@fordham.edu
.
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:
lobster.C
Copy your C++ program into your
public_html
directory.
For inspiration, see what the other students have done
here.
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.)