CS 180 Exam Two Terms and Concepts
Concepts from previous exam such as:
- program components, variables, data types and how to choose
them, various arithmetic operations, ways to control formatting of
output
Chapter 4
- relational operators: >, <, >=, <=, ==, !=, what can and
cannot be compared, how to handle comparison for floating point types
- bool type: true, false, boolalpha io manipulator
- if statement: conditional execution, else, else if,
nested if statements, always use braces
- logical operators: && (and, binary), || (or, binary), !
(not, unary), operands are Boolean, return value is Boolean
- truth tables: to explain logical operators
- relops and characters: use ASCII values for
comparison
- relops and strings: character by character
- conditional operator: var = x < 0 ? -x : y
- flag variables: Boolean variables that store a condition
value.
- scope: of a variable, the region of the program in which
the variable exists and can be referred to
Chapter 5
- increment/decrement operators: ++, --, prefix vs. postfix
form, be able to evaluate experssions that use these
- while loop: similar to if statement, pretest loop, body
executes zero or more times
- input validation: common use of while loops, useful
- counters and accumulators: incrementing
vs. accumulating, both very useful
- do while loop: posttest loop, will always execute at
least once, compare and contrast with regular while loop
- loop control with flags: while (!done) for example
- for loop: for (initialization; test; update),
understanding the number of loop iterations, nested loops, not using
break
and continue
.
- text file IO: what text files are, streams for reading
and writing, opening streams, using streams, closing streams, stream
extraction vs.
getline
Chapter 6
- functions: modularization, reuse, return type, parameter
list, special
void
return type
- function prototypes: declare them
- parameters: formal parameters vs. actual parameters (aka parameters
vs. arguments), formal: type and name, actual: value (could be
variable, expression, literal, etc. . .)
- naming functions: functions do something so
names should contain verbs
- return statements: where they can appear, make sure
functions always return
- global variables: just say no, global constants
are acceptable
- local variables: defined inside functions, scope is
function body, parameters are kind of like pre-initialized local
variables
- pass-by-value parameters: argument is copied
into formal parameter when function is called, formal parameter can
be used as a variable, but it is just a copy
- pass-by-reference parameters: reference variable is a
reference to another variable, declared using ampersand (&),
an alias for another variable, changes actually change real
variable, arguments must be variables
- function design: function should do only one thing