Unit 2 Flashcards
Control Structures (9 cards)
algorithm
a set of instructions or a procedure for solving a problem and the order in which the actions should execute
pseudocode
“fake” code that is easy to understand by everyone
flowchart
a diagram that displays the sequential order of steps and the flow of logic in a program
selection/decision statments
if, else, else if, switch
* if a condition is met, the block of code under the statement would be executed
repetition/iteration statements
- sentinel-controlled/conditional loops
- counter-controlled/counted loops
sentinel-controlled/conditional loops
an action that is to be repeated while some condition remains true
* while → condition is tested for first
* do-while → code will be executed first, then the condition is tested at the end
* break → will stop executing the code at a certain point
* continue → will continue executing the code and will not jump out of the condition
counter-controlled/counted loops
when the number of repetitions is known before the loop begins executing
* for loops → a while loop all in one line
* e.g. for (int num - 1; num < totalNum; num++)
* counter, condition, incrementation
brute-force
a programming style where programs are written in a tedious and repetition-heavy method
nesting
placing one control structure within another control structure