L-44 MCS 275 Fri 27 Apr 2001
Review Questions on Chapter 14
- The UNIX command cal displays the calendar of the current
month. To see the calendar for the month May of 2001, we type
prompt> cal 5 2001
and our friend, the computer shows us
May 2001
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
- Write a program that calls the UNIX command cal.
- Write a interactive program that prompts the user to
enter the number of the month and the year.
Then invoke the cal command with those arguments.
- Modify the program above to find out how many days
a particular month of some year has.
The last day is the last integer number displayed by cal.
- The UNIX command pwd prints the working directory.
-
Use the command pwd to write the function int depth ()
that returns the number of directories the current
working directory is away from the root (the / in UNIX).
(Hint: count the number of slashes / in what
pwd returns.)
-
PWD is also an environment variable on UNIX systems.
Use the environment variable PWD to implement
int depth().
- Consider the makefile
A: C
@echo 1
B:
@echo 2
C: B
@echo 3
Give the sequence of numbers displayed when the user types
- make A
- make B
- make C
FINAL EXAM in LC C3 on Monday 30 April 2001 at 1:00-3:00PM.