W3 - LOGIC Flashcards
W3-1 What is STRUCTURED PROGRAMMING? (SP)
_ is a programming PARADIGM aimed at improving the clarity, quality, and development time of a computer programming
_ SP consists of sets of simple CONSTRUCTS, each of which has 1 ENTRY point and 1 EXIT point.
W3-2 SEQUENTIAL CONSTRUCTS represent?
one statement follows another and the statements are executed in order
- SELECTION constructs and ITERATION constructs represent MODIFICATIONS of sequential constructs.
W3-2 SELECTION CONSTRUCTS represent?
different paths through the sets of instructions
W3-3 ITERATION CONSTRUCTS represent?
REPETITION of the SAME set of instructions until a specified condition has been met.
W3-4 To complete a programming language, how many classes of constructs are required?
3 classes of constructs:
1/ SEQUENTIAL CONSTRUCTS
2/ SELECTION CONSTRUCTS
3/ ITERATION CONSTUCTS
W3-5 What is the SIMPLEST example of a STRUCTURED construct?
_ a sequence
_ A sequence is either a SIMPLE STATEMENT or a CODE BLOCK
W3-6 What is a CODE BLOCK?
_ is a set of STATEMENTS enclosed in a pair of curly braces to be executed sequentially.
_ Unlike a SINGLE STMT, a C CODE BLOCK does not require a TERMINATING semi-colon of its own (after the closing brace)
W3-7 Well-established techniques include?
_ pseudo-coding
_ flow-charting
=> improve chances are that our coding will be clear and concise
W3-8 What is a PSEUDO-CODE?
is a set of shorthand NOTES in a human (non-programming) language that itemizes the KEY steps in the sequence of instructions that produce a programming solution.
W3-9 What is a FLOW CHART?
is a set of conventional SYMBOLS connected by arrows that illustrate the FLOW of control through a programming solution.
W3-10 The C language supports 3 SELECTION CONSTRUCTS?
_ OPTIONAL path (OP)
_ ALTERNATIVE paths (AP)
_ CONDITIONAL expression (CE)
W3-11 OPTIONAL PATH executes?
_ a SEQUENCE only if a certain condition is satisfied; that is, if the condition is TRUE.
_ OPTIONAL selection takes the form
if (condition)
sequence
- Parentheses enclose the condition, which may be a RELATIONAL expression or a LOGICAL expression
- The sequence may be a SINGLE STMT or a CODE BLOCK
W3-12 C language supports 2 ways of describing ALTERNATIVE PATHS?
_ an binary select construct
_ a multiple selection construct
W3-13 BINARY SELECTION CONSTRUCT executes?
_ one of a set of ALTERNATIVE SEQUENCES
_ Construct takes the form if (condition) sequence else sequence
- Parentheses enclose the condition, which may be a RELATIONAL expression or a LOGICAL expression
- The sequences may be SINGLE STMTs or CODE BLOCKS
- (P) executes the sequence following the IF only if the condition is TRUE
- (P) executes the sequence following the ELSE only if the condition is FALSE
W3-14 MULTIPLE SELECTION
For 3 alternative paths
=> append an IF ELSE construct to the ELSE keyword
W3-15 COMPOUND CONDITION
_ The CONDITION in a selection construct may be a COMPOUND CONDITION
_ A COMPOUND CONDITION takes the form of a LOGICAL EXPRESSION
W3-16 CASE-BY-CASE selection construct
compares a CONDITION - simple or compound - against a set of CONSTANT values or constant expressions.
_ This construct takes the form: switch (condition) { case constant: sequence break; case constant: sequence break; default: sequence }
W3-17 What is CONDITIONAL SELECTION CONSTRUCT?
is shorthand for the ALTERNATIVE path constuct
_ This TERNARY expression combines a condition and 2 sub-expressions using the ? : operator
condition ? operand : operand
W3-18 C language supports 3 ITERATION CONSTRUCTS?
_ while
_ do while
_ for
W3-19 What is an INFINITE LOOP?
If the CHANGE STMT is MISSING or if the TEST condition is always SATISFIED, the iteration continues without terminating and the program can NEVER terminate.
=> such an iteration is an INFINITE LOOP
W3-20 The WHILE construct
executes its sequence as long as the test condition is TRUE.
_ This construct takes the form:
while (condition)
sequence
W3-21 The DO WHILE construct
executes its sequence at least ONCE and continues executing it as long as the test condition is TRUE.
_ This construct takes the form:
do
sequence
while (condition);
W3-22 The FOR construct
groups the initialization, test condition and change together, seperating them with semi-colons.
_ This construct takes the form:
for (initialization; condition; change)
sequence
W3-23 What is FLAGGING?
is a METHOD of coding iteration constructs within the SINGLE-ENTRY SINGLE-EXIT rule of structured programming.
W3-24 What are FLAGS?
_ are VARIABLES that determine whether an iteration continues or stops
_ A flag is either TRUE or FALSE
_ Flags help ensure that NO paths cross one another.
W3-25 What is NESTING?
enclosing one LOGIC construct within another
W3-26 What is a NESTED SELECTION?
a selection within another selection
W3-27 What is DANGLING ELSE?
_ An ambiguity arises in a nested IF ELSE construct that contains an optional sequence (if)
_ (C) always attaches the dangling ELSE to the innermost IF.
W3-28 What is a NESTED ITERATION?
an iteration within another iteration