1/19
Flashcards covering spaghetti code, the three basic programming structures (sequence, selection, loop), Boolean logic, priming input, end-of-data handling, stacking and nesting of structures, and the benefits of structured programming as discussed in Lesson 3.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What is spaghetti code and why is it problematic?
Spaghetti code is unstructured program logic that does not follow structured programming rules; it is hard to read, hard to maintain, prone to errors, and difficult to reuse as building blocks for larger applications.

Name the three basic programming structures.
Sequence, selection, and loop.
An expression whose value can be true or false (often represented as yes/no or 1/0) and it controls decisions in selection and looping.
What is a Boolean expression and what values can it take?
In a flowchart, it starts with a decision symbol containing a Boolean expression; in pseudocode, it is described with if … endif (often with if…then…else).
How is a selection structure described in flowcharts and pseudocode?
An if statement with two branches: if condition is true then do one process, else do the other; ends with endif.
What is a dual-alternative if-else?
An if statement that executes an action only when the condition is true, with no else branch.
What is a single-alternative if?
Performs actions in order, one after another, with no branching or skipping of steps.
Describe the sequence structure.
A loop that tests a condition before the loop body; if true, executes the body, then re-evaluates the condition and repeats until false.
Describe the while loop and how it operates.
An initial input step that starts the data stream before entering the loop; helps ensure the loop can be structured and the end-of-data condition can be tested correctly.
What is a priming input and why is it used?
EOF is a sentinel indicating no more input; the test should occur immediately after an input statement to avoid unnecessary processing after eof.
What is end-of-data (eof) and where should the program-ending test occur?
Attaching structures end to end (sequence, selection, loop) to build larger programs.
What is stacking in structured programming?
Placing one structure inside another; can be nested to many levels; requires consistent start/end alignment.
What is nesting in structured programming?
Only combinations of sequence, selection, and loop; each structure has a single entry and a single exit; structures can be stacked or nested; results are readable and maintainable.
What are the key characteristics of a structured program?
A technique to untangle an unstructured flowchart by tracing paths and rearranging into structured blocks.
What is the spaghetti bowl method?
It improves clarity, professionalism, efficiency, and modularity; easier maintenance and modification; languages often enforce it.
Why is structuring code beneficial?
Dividing a program into modules with single entry/exit points; modules can be reused across programs, simplifying maintenance.
What is modularization and its benefits?
If it contains only sequence, selection, and/or loop blocks with single entry/exit points and proper nesting, it is structured.
How can you recognize a structured segment in a flowchart?
Represents a Boolean test in a selection structure; branches represent true/false outcomes and join back.
What is a decision symbol in flowcharts used for?
Pre-test loops evaluate the condition before each iteration; post-test loops evaluate after at least one execution, affecting whether they can run zero times.
What is the difference between pre-test (while) and post-test loops?
To prevent extraneous output after termination; achieved by testing for eof immediately after input and using a priming input with proper loop structure.
Why avoid printing after encountering eof, and how is this achieved structurally?