Do the prcs tutorial.
- Remember prcs is installed in ~sholden/pub/prcs/bin/prcs
Write a C++ program called is_even which reads a single integer
from std::cin, and then returns a true exit status if the integer is even,
and a false exit status if the integer is odd. Test your program with
the test_is_even shell script. Don't forget to
chmod +x test_is_even
The read shell command can be used to read a line from stdin into
a shell variable. Download and test the enter_name shell script so that you understand how
read works. The modify the enter_name shell script so that when
the name entered is your own name, the message "Hi $firstname, welcome
back" is output, and otherwise the message "Hi $firstname, pleased to meet
you" is output.
Modify the enter_age shell script so that
where in the first two cases cases, x is the age difference between the age
entered and your age. See if you can do it where your age occurs in the
source code only once. See if you can do it using only one echo statement
after the read statement.
- if the age entered is older than your age, the message "You are x years older than me" is output,
- if the age entered is younger than your age, the message "You are x years younger than me" is output, and
- if the age entered is the same as your age, the message "You are the same age as me" is output,
Repeat question 2, but this time make the is_even program be a
Enter the shell script from last Friday's lecture for compiling code, or
use your shell script from Question 3 of the Week 3 Friday tutorial.
Modify the shell script so that each .cc file is only compiled if it is
newer than the corresponding .o file.
Further modify the shell script from the previous question so that the
final program is only linked if any of the .cc files were recompiled.
The wait_for_file shell script is the infinite
while loop code from today's lecture, with some echo statements to show
where it's up to (and some other small changes). Run the shell script,
then get another xterm and in it, run the command
echo "Hello world" > file.txt
to create the file.txt file. Observe the shell script exit and
delete file.txt when this happens.
Rewrite the code from the previous question so that no if statement is
used. (Hint: inside square brackets [ ], you can use ! as "not", just like
The example_parameters shell script is the
example parameters code from today's lecture. Modify it so that only the
1st, 3rd, 5th, etc parameters are be output.
Rewrite the code from the previous question so that the 2nd, 4th, 6th, etc
parameters are output.
Write a shell script which works like the join function from
Question 6 of the Week 1 Friday tutorial. That is, it
should work as follows:
bash$ ./join fred hello how are
(You need to use "./join" because otherwise you will accidentally
run the Unix join utility.)
for i; do
is another way of writing the original example_parameters shell script from Question
10, with the advantage that it doesn't destroy the parameters $1, $2, etc
by shifting them. Rewrite the previous question using only this form of
for loop (ie. don't use shift at all).
The multiple_tests shell script is the
multiple tests code from today's lecture. Modify it so that it works with
your Assignment 1 submission and the sample assignment 1 input-output test
Modify the code from the previous question so that it exits with a true
exit status if all the tests are passed, and it exits with a false exit
status is one or more of the tests fail.
Modify the code from the previous question so that the exit status it
exits with is the number of tests which were failed. In addition, before
exiting it should output a summary which looks like this:
Summary: x/y tests passed
where x is the number of tests passed, and
y is the total number of tests.