Class 2 - Control Structures and Functions
Class Dates
- Section MMY3A: Tuesday, February 13 (College follows Monday schedule)
- Section TTC3A: Tuesday, February 20
- Section FFC3A: Friday, February 16
Goals
- Introduce the language constructs for sequence,
selection, and repetition.
- Introduce the Logical Operators.
- Introduce Program Modules and Functions.
Topics
- The if ... else selection structure
- The logical operators,
&&
, ||
,
and !
- The while, for, and do ... while repetition structures
- The switch multiple selection structure
- Function prototypes, function definitions, and function references
- Function example: Random number generation
- Scope rules
- Functions with empty parameter lists
Reading Assignment
Chapters 2 and 3 of the textbook.
Homework
Do the Self Review exercises at the end of Chapter 2 (2.1 through 2.13)
and check your own work. Do not hand in the answers.
The following assignment is due the day of Class_3.
Write C++ programs to answer each of the following exercises:
- Exercises 2.15, 2.20, 2.26, 2.27, 2.47
- Exercises 3.11, 3.20
When all of the programs compile and run correctly, put all the source
files (and only the source files) into a directory, tar the
directory and e-mail it to your instructor. Be sure you name the
tar file and attach it to your e-mail message as described in
Submitting a Project.
Use the following code as a model for the block of comments you are
to put at the beginning of each source file:
/* exercise_2.15.cc
*
* This program prints ... <tell what the program does>
*
* <put your name here>
* <put the date here>
*
*/
Christopher Vickery
Ruben Lusinyants
Queens College of CUNY
Dr. Vickery's Home Page