CPS 6.3,4 Ramm - Fall 2000 - 9/8/00 #6
- Announce
- Quiz Today
- Do-It-Yourself (print)
- Assignment #2 on Web Page
- Lab #2 on Web Page
Chap 4: Control, Function, and Classes
-
if Statement
if ( test expression )
{
statement list;
}
-
if/else Statement
if ( test expression )
{
statement list;
}
else
{
statement list;
}
-
if/else Example:
- Relational Operators
| == | equal to
|
| > | greater than
|
| < | less than
|
| != | not equal to
|
| >= | greater than or equal to
|
| <= | less than or equal to
|
-
if/else Trivial Sort Example:
- Assignment Statement: ... = ...
- Pronounce gets rather than equals
- Example with if/else and assignments:
firstof3.cpp
- Value of Relational Operations
true = 1
false = 0
- Logical Operators
- Short Circuit Evaluation
exhaust4.cpp
- C++ Operator Precedence
| ! | NOT
|
| *, /, % | mult, div, mod
|
| +, - | add, subt
|
| <<, >> | insert, extract
|
| <, <=, >, >= | LT, LE, GT, GE
|
| ==, != | EQ, NE
|
| && | AND
|
| || | OR
|
| =, +=, -=, *=, /=, %= | assignment
|
When in doubt, parenthesize
- Functions that Return Values
math.cpp
- Writing
Double Functions
tfuncts.cpp
- Use Functions Like Variables
- Writing
string Functions
getgrade.cpp,
getgradealt.cpp
- Design Different "Curving" Functions
- Writing Functions
Design Different "Curving" Functions