# Chapter 3: Understanding Structure

### 38 terms by dreaminatnite

#### Study  only

Flashcards Flashcards

Scatter Scatter

Scatter Scatter

## Create a new folder

- The features of unstructured spaghetti code - The three basic structures--sequence, selection, and loop - Using a priming input to structure a program - The need for structure - Recognizing structure - Structuring and modularizing unstructured logic

### Spaghetti code

is snarled, unstructured program logic.

### Unstructured programs

are programs that do not follow the rules of structured logic.

### Structured programs

are programs that do follow the the rules of structured logic.

### Structure

is a basic unit of programming logic; each structure is a sequence, selection, or loop.

### Sequence structure

you perform an action or task, and then you perform the next action, in order. A sequence can contain any number of tasks, but there is no option to branch off and skip any of the tasks.

### Selection structure

or decision structure, you ask a question, and depending on the answer, you take one or two courses of action. Then, no matter which path you follow, you continue with the next task.

### if-then-else

is another name for a selection structure.

### Dual-alternative ifs

or single-alternative selections, define one action to be taken when the tested condition is true and another action to be taken when it is false.

### Single-alternatives ifs

or single-alternative selections, take action on just one branch of the decision.

### Null case

is the branch of a decision in which no action is taken.

### Loop structure

you continue to repeat actions based on the answer to a question.

### Repetition and Iteration

are alternate names for a loop structure.

### While loop

a process continues while some condition continues to be true.

### Stacking structures

is the act of attaching structures end to end.

### End-structure statements

designate the ends of pseudocode structures.

### Nesting structures

is the act of placing a structure within another structure.

### Block

is a group of statements that executes as a single unit.

### Priming input

is the statement that reads the first input data record prior to starting a structured loop.

### Goto-less programming

is a name to describe structured programming, because structured programmers do not use a "go to" statement.

b. spaghetti

### The three structures of structured programming are __________. a. sequence, order, and process b. selection, loop, and iteration c. sequence, selection, and loop d. if, else, and then

c. sequence, selection, and loop

d. if-then-else

d. nesting

a. stacking

### The statement if age >= 65 then seniorDiscount= "yes" is an example of a _________. a. sequence b. loop c. dual-alternative selection d. single-alternative selection

d. single-alternative selection

b. loop

### The statement if age<13 then movieTicket= 4.00 else movieTicket= 8.50 is an exampleof a _________. a. sequence b. loop c. dual-alternative selection d. single-alternative selection

c. dual-alternative selection

### Which of the following attributes do all three basic structures share _________. a. Their flowcharts all contain exactly three processing symbols. b. They all have one entry and one end point. c. They all contain a decision. d. They all begin with a process.

b. They all have one entry and one end point.

### Which is true of stacking structures. a. Two incidences of the same structure cannot be stacked adjacently. b. When you stack structures, you cannot nest them in the same program. c. Each structure has only one point where it can be stacked on top of another. d. When you stack structures, the top structure must be a sequence.

d. When you stack structures, the top structure must be a sequence.

### When you input data in a loop within a program, the input statement that precedes the loop _________. a. is the only part of the program allowed to be undstructured b. cannot result in eof c. is called a priming input d. executes hundreds or even thousands of times in most business

c. is called a priming input

a. block

### Which of the following is not a reason for enforcing structure rules in computer programs? a. Structuctured programs are clearer to understand than unstructured ones. b. Other professional programmers will expect programs to be structured. c. Structured programs usually are shorter than unstructured ones. d. Structured programs can be broken down into modules easily.

c. Structured programs usually are shorter than unstructured ones.

### Which of the following is not a benefit of modularizing programs? a. Modular programs are easier to read and understand than nonmodular ones. b. If you use modules, you can ignore the rules of structure. c. Modular components are reusable in other programs. d. Multiple programmers can work on different modules at the same time.

b. If you use modules, you can ignore the rules of structure.

### Which of the following is true of structured logic? a. You can use structured logic wwith newer programming languages, such as Java and C# but not older ones. b. Any task can described using some combination of the three structures. c. Structured programs require that you break the code into easy-to-handle modules that each contain no more than five actions. d. All of these are true.

b. Any task can described using some combination of the three structures.

### Which of the following is not another term for selection structure? a. decision structure b. if-then-else structure c. dual-alternative selection d. loop structure

d. loop structure

### Which of the following is acceptable is a structured program? a. placing a sequence within the true half of a dual-alternative decision b. placing a decision within a loop c. placing a loop within one of the steps in a sequence d. All of these are acceptable.

d. All of these are acceptable.

### In a loop, the structure-controlling question is ___________. a. asked exactly once b. never asked nore than once c. asked before and after the loop body executes d. asked only if it is true, and not asked if it is false

c. asked before and after the loop body executes

Example: