LOOPING STRUCTURES TERMINLOGIES

0.0(0)
studied byStudied by 44 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/53

flashcard set

Earn XP

Description and Tags

TERMINOLOGIES ONLY

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

54 Terms

1
New cards

Loop

A part of a program that repeats

2
New cards

Loop body

Contains the statements to be repeated

3
New cards

Looping Statement, The Condition, Initializing Statement, Statement that allows the condition to become false

4 Elements of a Loop Structure

4
New cards

Looping statement

while, for, and do while

5
New cards

Initializing Statement

Placed before the condition to ensure correct loop execution the first time the condition is evaluated

6
New cards

Statement that allows the condition to become false

ex. counter++, counter--, get a new input(for sentinel-controlled loop)

note: if one of these is missing, the loop will not work properly

7
New cards

Pre-test loop

The condition is tested first, if it is true the body of the loop is executed. This process repeats until the condition becomes false. Then the next statement after the loop is executed. Examples of _______________ are while and for loop

8
New cards

Post-test loop

The body of the loop is executed first before the condition is tested.

This process repeats until the condition becomes false.

Then the next statement after the loop is executed.

In this type of loop the body of the loop is executed at least once.

The do while is an example of such loop

9
New cards

Flowchart of Pre-test Loop

This flow chart is an example of what type of loop?

<p>This flow chart is an example of what type of loop?</p>
10
New cards

Flowchart of Post-test Loop

This flow chart is an example of what type of loop?

<p>This flow chart is an example of what type of loop?</p>
11
New cards

Iteration

each repetition in a loop. If the statements inside the loop are repeated 10 times then there are 10 __________

12
New cards

Counter-controlled loops

Type of loop where the number of iteration is known before the loop is executed. It uses a counter variable. its repetition is managed by a loop control variable whose value represent a count.

13
New cards

The While Loop

It has 2 important parts: (1) an expression that is tested for a true or false value, and (2) a statement or block that is repeated as long as the expression is true.

14
New cards

Prior

We use a counter-controlled loop when we can determine _______ to loop execution exactly how many iterations will be needed. This number should appear as the final value

15
New cards

The For Loop

Ideal for situations that require a counter (fixed iteration). ______________ can be used to count up or down by any interval.

16
New cards

Initialization, Condition, Statement/s, Update

For For Loop: First, the ___________ is executed. Then, the _________ is tested, if it is true, the __________ inside the loop are executed, and then the __________. Until the loop ends.

17
New cards

The Do While Loop

First, the initialization is executed. Then, the statement/s inside the loop are executed, and then the update. Then, the condition is tested, if it is true,

18
New cards

Sentinel

Data values used to signal either the start or end of a data series. Not part of the data series.

19
New cards

Sentinel Value

must be selected so as not to conflict with legitimate data values.

20
New cards

Break

forces an immediate break or exit from while, for, and do_while statements

21
New cards

Continue

When _________ is encountered in a loop, the next iteration of the loop will immediately begin

22
New cards

Loops

can be used to validate your inputs. If an invalid data is entered, a ________ can be used to ask the user to re-enter a data until a valid value is entered.

23
New cards

Validation Loop

In creating a ___________, the condition is always opposite to the valid values.

24
New cards

Flag-Controlled Loop

Uses a boolean variable (called a flag variable) to control the logical flow of the program.

25
New cards

True, False

set the boolean variable to ___________ before the loop and reset it to ________ when you need to exit the loop.

26
New cards

Initialize, Test, Update

Flag-Controlled Loop Design Rules:

1. _________ a flag (to true or false). Make sure that you use a meaningful name for the flag

2. ______ the flag in the loop test expression.

3. ________: A condition in the loop body that changes the value of the flag (to false or true)

27
New cards

Nested Loop

If a loop exists inside the body of another loop, it's called a _________.

28
New cards

Loop Condition or Condition

The logical expression is called a ____________ or simply a ___________.

29
New cards

Statement

Is called the body of the loop

30
New cards

Parentheses

The ____________ around the logical expression are part of the syntax.

31
New cards

Entry Condition

The logical expression provides an ___________.

32
New cards

Infinite Loop

A loop that continues to execute endlessly is called an ___________.

33
New cards

Loop Control Variable (LCV)

The variable i (Line 2) in the expression is called the______________. The expression checks whether a variable(s), called the ____________, satisfies certain conditions.

<p>The variable i (Line 2) in the expression is called the______________. The expression checks whether a variable(s), called the ____________, satisfies certain conditions.</p>
34
New cards

Sentinel

You might not know exactly how many times a set of statements needs to be executed, but you do know that the statements need to be executed until a special value is met. This special value is called a __________.

35
New cards

Sentinel-Controlled While Loop

The while loop continues to execute as long as the program has not read the sentinel. Such a while loop is called a __________________________.

36
New cards

Flag Variable

The variable, such as found, which is used to control the execution of the while loop, is called a ________.

37
New cards

EOF (End Of File)-controlled while loop

The programmer sometimes does not know what the sentinel is. In such situations, you can use an ___________________.

38
New cards

For Loop Controls

The initial statement usually initializes a variable (called the _______________, or indexed, variable).

39
New cards

Counted or Indexed

The for loop is typically called a __________ or ________ for loop.

40
New cards

Do While Loop

The _______ is useful when it does not make sense to check a condition until after the action occurs.

41
New cards

Software Patch

A __________ is a piece of code written on top of an existing piece of code and intended to remedy a deficiency in the original code.

42
New cards

While, For, Do While

Java has three looping (repetition) structures: ______, _______, _______

43
New cards

Reserved Word

In Java, while is a _____________.

44
New cards

Parentheses

In a while statement, the ___________ around the logical expression, the loop condition, are required; they mark the beginning and end of the expression.

45
New cards

Counter

A counter-controlled while loop uses a _________ to control the loop.

46
New cards

False

The body of the while loop typically contains statement(s) that eventually set the expression to _______ to terminate the loop.

47
New cards

Initialize

In a counter-controlled while loop, you must __________ the counter before the loop, and the body of the loop must contain a statement that changes the value of the counter variable.

48
New cards

Similar, Different

The sentinel must be ______, yet ________ from all the data items.

49
New cards

While, For, Do While

Java Reserved Words

50
New cards

Simplifies

A for loop __________the writing of a counter-controlled while loop.

51
New cards

Semicolon

If you put a ____________ at the end of the for loop (before the body of the for loop), the action of the for loop is empty.

52
New cards

Terminates

Executing a break statement in the body of a loop immediately ___________ the loop.

53
New cards

Might Not Execute

When a continue statement executes in a while or do...while loop, the update statement in the body of the loop ______________

54
New cards

Next Statement

After a continue statement executes in a for loop, the update statement is the ________________ executed.