UMBC CMSC202, Computer Science II, Spring 1998,
Sections 0101, 0102, 0103, 0104 and Honors
Tuesday January 27, 1998
- A Book on C: 6.1-6.6 and 11.1-11.5
- Programming Abstractions in C: 2.1-2.5 and 3.4
Handouts (available on-line):
- Prerequisites for CMSC 202:
FAQ on Introductory Computer Science Courses on material
that you are expected to know from CMSC 201.
For example, you should really understand parameter passing
- Noted the existence of the course web page, which you already know
about if you are reading this page. (Reminder:
check in if you haven't already.)
- Went over course description.
Note: the Roberts textbook is optional. Also, you will be required to
purchase Dr. Mayfield's excellent notes on pointers "Understanding
Pointers in C" for $6.50. The notes will be available in the
- Went over course syllabus and
project policy. NB: I'm serious
about catching cheaters on the projects. Read over the
course policy on cheating well.
- Motivational lecture on how to learn advanced programming skills.
Main point: you should be able to sort out the syntactic issues
by now. In this course you need to consider higher-level issues
in data structures and problem-solving strategies.
- One way to learn how to use new features in a programming language
is to understand simple programs and learn how to generalize from
the simple example. In the following sequence of programs, we first
examine the use of parameter passing by reference for integers.
We also examine a simple program that uses structures. From the
two, we are able to concoct a program that passes structure parameters
- A simple function:
- A simple function with an integer reference parameter:
- A simple program that uses structures:
- A simple function that takes a structure as
a parameter and returns a structure value:
Note that the syntax in this function is not much different
from the syntax for the function which takes an integer
parameter and returns an integer value.
- A revision of the previous function which
fixes a problem where the minute field might exceed
- Finally, we write a function that takes a structure
This function fixes the minute field of the parameter if the
field exceeds 60 minutes. Note that the syntax for
accessing the field of the structure parameter is
(*p).minute. The parentheses are necessary because
the . operator has a higher precedence than the
dereference * operator. C provides a short cut
notation, p->minute is identical to
(*p).minute. Nevertheless, the mechanism for
working with reference parameters is essentially the same as
that of our second program.
23 Mar 1998 13:06:34 EST
to Spring 1998 CMSC 202 Section Homepage