Lesson 3: Fundamentals of Programming - Study Flashcards

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/19

flashcard set

Earn XP

Description and Tags

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.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

20 Terms

1
New cards

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.

2
New cards
<p>Name the three basic programming structures.</p>

Name the three basic programming structures.

Sequence, selection, and loop.

3
New cards

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?

4
New cards

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?

5
New cards

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?

6
New cards

An if statement that executes an action only when the condition is true, with no else branch.

What is a single-alternative if?

7
New cards

Performs actions in order, one after another, with no branching or skipping of steps.

Describe the sequence structure.

8
New cards

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.

9
New cards

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?

10
New cards

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?

11
New cards

Attaching structures end to end (sequence, selection, loop) to build larger programs.

What is stacking in structured programming?

12
New cards

Placing one structure inside another; can be nested to many levels; requires consistent start/end alignment.

What is nesting in structured programming?

13
New cards

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?

14
New cards

A technique to untangle an unstructured flowchart by tracing paths and rearranging into structured blocks.

What is the spaghetti bowl method?

15
New cards

It improves clarity, professionalism, efficiency, and modularity; easier maintenance and modification; languages often enforce it.

Why is structuring code beneficial?

16
New cards

Dividing a program into modules with single entry/exit points; modules can be reused across programs, simplifying maintenance.

What is modularization and its benefits?

17
New cards

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?

18
New cards

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?

19
New cards

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?

20
New cards

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?