CMPUT 201 Assignment #1
Due before 23:59, Sunday, February 11,
The assignment consists of a series of small programming tasks intended
to make you familiar with C/C++ syntax and with the UNIX way of doing things.
Each task is fairly independent and you can start them whenever you are
ready. The first few exercises are simple enough that you can do them right
away. They require a knowledge of the C material in the first first thirteen
chapters of King's book (or the first eight Chapters of Kernighan and Ritchie--that
is the whole book), or the first five chapters of Deitel & Deitel.
After completing this assignment you should be able to do simple programming
tasks and be comfortable with the larger ones in the coming weeks.
You can do this assignment in C alone or in C/C++ (using the g++ compiler).
If you are new to C/C++, you might want to focus on C and use King's book
(or the standard C reference by Kernighan and Ritchie).
Read this assignment through carefully to make sure that you understand
what is to be done, what should be handed in, and the format of the submission.
Generally, your programs should comply with the guidelines in Notes
on Specification and Coding Style. That material, however, assumes
that you already know C.
Collaboration is not allowed for this assignment,
that is, each of you must do the task on your own. Obviously you can, and
even should, DISCUSS the assignment and its possible solutions with others
in your lab section, but you must write your own solutions. We assume that
you are aware of the Regulations
undergraduates should know, as
stated in Undergraduate
Laboratories WWW Server
The assignment consists of a sequence of fairly independent exercises
and you can work on them whenever you are ready. You should start them
right away, this will guide your study of the C/C++ programming language.
In Lab 1 you will be shown how to use CVS and to construct a makefile
that will be used to create executable modules of all your programs when
"make all" is typed. Ensure that the executables produced by your
makefile are named exactly as shown in the sample from the lab. If they
are not named correctly, they will not be marked!
There are many details that must be handled for you to receive full
marks on this assignment. You should pay attention to these details. The
makefile must correctly produce all the programs required, and each function/procedure
and program file must be correctly named and must behave in the appropriate
way. If the details aren't addressed successfully you will lose marks.
You will not have to take action to submit your assignment. Your work
will be automatically extracted from your CVS repository on the due date
and time. We will also be extracting from your repository at times prior
to the due date in order to monitor your progress toward the final submission.
Questions about these exercises will be answered in the course newsgroup.
You are expected to check that newsgroup regularly, so that you are fully
Complete the following exercises, which are typical of the practice problems
found in many C/C++ programming texts. The exercises are stated in
general terms: this has been done on purpose to make you think about possible
solutions. If necessary, clarifications will be given in the course newsgroup,
in the labs or in class. The exercises are not specifically ordered by
difficulty. By using your makefile effectively you can tackle the
problems conveniently and in any order you wish. NOTE: For the first several
exercises, use getchar() and scanf() to read from standard input, and putchar()
or printf() to output your answers. For the later exercises the more general
functions like fgetc(), fgets() and the like may be better. See also the
IMPORTANT NOTE near the end of the assignment statement about multiple-line