If you did not do assignment 1, you are likely to be instructor dropped from the class...
If you haven't already, sign up for the class mailing list. I have already given instructions for account setup and information about project 1, in addition to having answered questions. And only list members can view the archives.
CS151 -- Administration Notice
You should have read Chapter 1 and part of chapter 2 by today!We are doing Chapter 2 today...
Project 1 is posted, and due next Friday, by midnight:
http://www.cs.unm.edu/~storm/C++/cs151_summer2001/Assignment1.html
Flow of Control
More on Statements
- keyword { <one or more statements> }
- <an executable statement>
- #pre-processorDirective
CS151 -- Shawn Stoffer
Flow of Control
More on Statements
- keyword { <one or more statements> }
- keyword == if, else, while, for, do, etc...
- why the braces?
CS151 -- Shawn Stoffer
Flow of Control
More on Statements
- keyword { <one or more statements> }
- the braces actually ARE a statement...
- they group statements
CS151 -- Shawn Stoffer
Flow of Control
More on Statements
- <an executable statement>
- always ends in ';'
- can be any valid C++ statement
CS151 -- Shawn Stoffer
Flow of Control
More on Statements
- Pre-Processor Directives
- Interpreted before compilation
- always begin with '#'
- EVERYTHING from the directive to a new-line ('\n')
CS151 -- Shawn Stoffer
Flow of Control
- Expressions
- statements that evaluate to a boolean, or psuedo-boolean
- go in the parens next to the if...
- if (expression) {}
CS151 -- Shawn Stoffer
Flow of Control
- Expressions
- ==, >, <, >=, <=, !=
- Just as statements can be joined together by putting them in braces ({ }), expressions can be joined together by using && (and) and || (or)
CS151 -- Shawn Stoffer
Flow of Control
- Expressions
- &&, ||
- Need the two symbols... & and | are two entirely different operators.
CS151 -- Shawn Stoffer
Variables Revisited
- Getting the contents of a variable...
- all of the operators operate on the contents of a variable
- different types of contents of variables
CS151 -- Shawn Stoffer
Variables Revisited
- Types of variables contents
- variables contain different things based on types...
- int type or floating point types, just the number...
- string types == "something"
- char types == 'a'
- boolean types == true or false
CS151 -- Shawn Stoffer
Flow of Control
- The switch statement (case statements)
- switch (an ordinal variable) {
case value1: statement; break;
case value2: statement; break;
...
default: statement; break;
CS151 -- Shawn Stoffer
Flow of Control
- The switch statement (case statements)
- an ordinal variable
- A variable that has an implicit order, such as an int, or char.
- Further something that has discrete values, not a double or float
- must be something that logically has cases
CS151 -- Shawn Stoffer
Flow of Control
- The switch statement (case statements)
- why statement; break;
- statement is executed, and if you don't specify break, it will simply go on and see if any of the other cases match...
- if/else if/else if/else
CS151 -- Shawn Stoffer
Flow of Control
- The switch statement (case statements)
- default keyword
- same as the else statement
CS151 -- Shawn Stoffer