CPS 6, Ramm - Summer Semester I - 6/1/99 #9
- Announce
- Test Tomorrow, review Today
- See sample test on web
- Assignment #3
Chapt 5. Iteration with Programs and Classes
- Defining Constants
const type identifier = value;
all caps
- Pre-tested and Post-tested Loops
- Iteration (post-tested)
- initialization
- loop body
- update
- loop test
-
do-while Loop Syntax
- do
- {
- statement list
- } while ( test expression )
- Using the
do-while Loop
addwhile.cc
- Infinite Loops
- Nested Loops
multable.cc
done previously by using function
e.g. roll300.cc
- Scope of Variables
- definition
- braces { }
- Private Variables
- Global Variables (XXX)
Chap 6. Sequential Access: Streams & Iterators
- Stream Iteration: Counting Words
- white space
- ' ', '\t', '\n'
- sentinel
- buffered input
-
cin.fail()
-
while (cin >> word)
wordcount.cc
- UNIX input redirection
program < filename
- Input File Streams
-
#include
-
ifstream streamname
-
streamname.open(filename)
-
streamname >> variable
wordcount2.cc