Chapter 3 Flashcards
what is spaghetti code
messy programs that are difficult to read
structure
basic unit of programming logic
what are the three types of structures
- sequence
- selection (decision)
- loop
sequence structure
performs tasks in order
selection structure (decision structure)
- takes one of two actions based on testing condition. (AKA evaluating a Boolean expression)
- also called if-then-else
- dual-alternative ifs or single-alternative ifs
loop structure
repeat actions while a condition stays true
dual-alternative ifs
- contains 2 alternatives
- if-then-else structure
single-alternative ifs
if-then structure
null case
situation where nothing is done
loop structure (repetition/iteration)
- repeats a set of actions while a condition stays true (loop body)
- “while…do” or “while loop”
stacking structures
attaching structures end to end
end-structure statement
indicates end of a structure
what statement ends an if-then-else structure
endif
what statements ends a loop structure
endwhile
nesting structure
- placing one structure within another
What characteristics are in structures programs
- includes combination of three basic structures
- single entry point and single exit point
priming input ( priming read)
reads first input data record
is outside the loop that reads rest of the records
helps keep program structured