Intro
C: Study Guide
This
guide does not include topic
detail
Chapters 4, 5, 6
Operators
Arithmetic:
+ - * / (integer and float) %
Assignment:
=
Compound
assignment:
+= -=
*= /= %=
Increment/Decrement:
++ --(prefix and postfix)
Indirection/dereference:
*
Address: &
sizeof
cast
Relational
>=
>
<= <
Equality
!= ==
Logical
!
&& ||
Precedence and associativity
Concepts
of programming
Structured
programming: 3 basic control structures (sequence, including fn calls,
selection, repetition)
Top-down
design
Stepwise
refinement (factoring, decomposition, modularization)
Benefits
of using functions
Ease
of maintenance: small problems easier to code, debug, maintain than
large
Reusability
once written and debugged, just use, whether multiple calls in same pgm
or using in different programs
if have to modify, only need to change in one place
rather than hunting down duplicate
code
Data
protection
Miscellaneous
fn topics
Structure chart
IPO chart
Local
vs. global variables
Calling
vs. called functions
Builtin
vs. user-defined functions
Boolean
functions
Input
vs. output parameters
Formal
vs. actual parameters
Communication
between functions done with parameters and return values
fn can take 0 or more parameters
fn can return 0 or 1 value only
Pass-by-value
vs. pass-by-reference
How to use each
Why to use each
Rules
of thumb regarding output param vs. return value
Random
number generation (pseudo)
Seeding the PNG with constant or system time
Generating random number
range of random numbers: scale and shift
Math
functions
sqrt,
pow
compile
with –lm option
math.h
Selection
if, if-else, if-elseif (coding style seen as if-else by compiler)
Flowchart
diagrams
DeMorgan's law
Avoid coding the negative
No null if or else statements
if null if, make if (!cond) and have
body of else be body of
if
if null else, simply eliminate: an if
doesn't need an else
Nested if
Dangling else
switch
conditional operator
Data
validation
scanf() return value of EOF or number of successful conversions
Iteration
finite vs. infinite loops
pretest vs. posttest loops
status-controlled vs. counter-controlled loops
Flowchart
diagrams
loop
initialization, control, process, update
while
for
do-while
nested loops
jump statements
break: only acceptable in switch
statement
continue: not acceptable
return: only acceptable once
sequentially at end of function
goto: not acceptable
Builtin
character-processing Boolean functions
isalpha
isupper
islower
isdigit
ispunct
isspace
Builtin
character conversion functions
toupper
tolower
Return value of each must be captured or somehow used