W3 - LOGIC Flashcards

1
Q

W3-1 What is STRUCTURED PROGRAMMING? (SP)

A

_ 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

W3-2 SEQUENTIAL CONSTRUCTS represent?

A

one statement follows another and the statements are executed in order

  • SELECTION constructs and ITERATION constructs represent MODIFICATIONS of sequential constructs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

W3-2 SELECTION CONSTRUCTS represent?

A

different paths through the sets of instructions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

W3-3 ITERATION CONSTRUCTS represent?

A

REPETITION of the SAME set of instructions until a specified condition has been met.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

W3-4 To complete a programming language, how many classes of constructs are required?

A

3 classes of constructs:
1/ SEQUENTIAL CONSTRUCTS
2/ SELECTION CONSTRUCTS
3/ ITERATION CONSTUCTS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

W3-5 What is the SIMPLEST example of a STRUCTURED construct?

A

_ a sequence

_ A sequence is either a SIMPLE STATEMENT or a CODE BLOCK

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

W3-6 What is a CODE BLOCK?

A

_ 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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

W3-7 Well-established techniques include?

A

_ pseudo-coding
_ flow-charting
=> improve chances are that our coding will be clear and concise

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

W3-8 What is a PSEUDO-CODE?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

W3-9 What is a FLOW CHART?

A

is a set of conventional SYMBOLS connected by arrows that illustrate the FLOW of control through a programming solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

W3-10 The C language supports 3 SELECTION CONSTRUCTS?

A

_ OPTIONAL path (OP)
_ ALTERNATIVE paths (AP)
_ CONDITIONAL expression (CE)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

W3-11 OPTIONAL PATH executes?

A

_ 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

W3-12 C language supports 2 ways of describing ALTERNATIVE PATHS?

A

_ an binary select construct

_ a multiple selection construct

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

W3-13 BINARY SELECTION CONSTRUCT executes?

A

_ 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

W3-14 MULTIPLE SELECTION

A

For 3 alternative paths

=> append an IF ELSE construct to the ELSE keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

W3-15 COMPOUND CONDITION

A

_ The CONDITION in a selection construct may be a COMPOUND CONDITION

_ A COMPOUND CONDITION takes the form of a LOGICAL EXPRESSION

17
Q

W3-16 CASE-BY-CASE selection construct

A

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
}
18
Q

W3-17 What is CONDITIONAL SELECTION CONSTRUCT?

A

is shorthand for the ALTERNATIVE path constuct

_ This TERNARY expression combines a condition and 2 sub-expressions using the ? : operator
condition ? operand : operand

19
Q

W3-18 C language supports 3 ITERATION CONSTRUCTS?

A

_ while
_ do while
_ for

20
Q

W3-19 What is an INFINITE LOOP?

A

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

21
Q

W3-20 The WHILE construct

A

executes its sequence as long as the test condition is TRUE.

_ This construct takes the form:
while (condition)
sequence

22
Q

W3-21 The DO WHILE construct

A

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);

23
Q

W3-22 The FOR construct

A

groups the initialization, test condition and change together, seperating them with semi-colons.

_ This construct takes the form:
for (initialization; condition; change)
sequence

24
Q

W3-23 What is FLAGGING?

A

is a METHOD of coding iteration constructs within the SINGLE-ENTRY SINGLE-EXIT rule of structured programming.

25
Q

W3-24 What are FLAGS?

A

_ 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.

26
Q

W3-25 What is NESTING?

A

enclosing one LOGIC construct within another

27
Q

W3-26 What is a NESTED SELECTION?

A

a selection within another selection

28
Q

W3-27 What is DANGLING ELSE?

A

_ 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.

29
Q

W3-28 What is a NESTED ITERATION?

A

an iteration within another iteration