Week 10 Flashcards

1
Q

o The 3 structures used in structured programming (includes Java)

A

 Sequence
 Selection (decision)
 Repetition (loop)

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

o The repetition structure allows for a ________ of statements to be repeated

A

 Sequence

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

o An advantage of Repetition structures is that they reduce

A

 The amount of coding required, and make it easier to maintain software

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

o Another name for a while loop

A

 Pretest loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  • What is a Loop Control Variable?
A

o Part of the Boolean expression controlling the loop

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

o The statements inside of the loop change the ____ ______ ________ so that the loop will eventually stop repeating

A

 Loop control variable

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

o 3 Towers of using a loop control variable 3 things are needed

A

 1. Initialize the loop control variables before entering the loop
 2. Provide a condition that controls the loop
 3. Alter the loop control variable within the loop, so that eventually the condition becomes false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  • Definite Loop and Indefinite Loop
A

o Definite: A loop that executes a pre-determined number of times (Ex. Counter loop control variable that goes up or down by 1)
o Indefinite: A loop controlled by user input

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

o A loop control variable within an indefinite loop is called

A

 A Sentinel value

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

o Steps to applying a loop in an existing program

A

 Identify parts of the program that repeat
 Use a loop for the repetitions
 Test boundary conditions that control the loop

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

o Loop mistakes:

A

 Not following the 3 towers
 Using the wrong comparison operator
 Placing statements inside of the loop that belong outside

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

o For loop

A

 Similar to a while loop, but the initialization, condition, and increment are all on the same line

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

 How is a for loop diagramed?

A
  • The exact same way as a while loop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

o A do-while loop is also called

A

 A post-test loop

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

o This loop performs all of the statements, then checks if it should repeat at the end

A

 Do-while loop

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

o Common Loop applications

A

 Detect min/max value, Detect matching value
 Validate data, accumulate totals