Chapter 6_The Repetition Structure

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

1/45

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

46 Terms

1
New cards

Repetition structure (or loop)

Repeatedly processes instructions until condition is met

2
New cards

Looping condition

The requirement for repeating the instructions

3
New cards

Loop exit condition

The requirement for not repeating the instructions

4
New cards

Pretest loop

Evaluates condition prior to processing instructions

5
New cards

Posttest loop

Evaluates condition after processing instructions

6
New cards

Do…Loop statement

  • Used to code both pretest loop and posttest loop

  • Begins with Do clause, ends with Loop clause

  • Instructions to be repeated are placed between Do and Loop clauses

  • Use While or Until keyword before condition

  • Condition must evaluate to Boolean True or False

7
New cards

While keyword,

Until keyword

Two variations of syntax

  • One for pretest loop and one for posttest loop

8
New cards

While keyword

Indicates that instructions should be processed while condition is true

9
New cards

Until keyword

Indicates that instructions should be processed until condition becomes true

10
New cards

Pretest loop

Appears in Do clause

11
New cards

Posttest loop

Appears in Loop clause

12
New cards

Diamond

Represents loop condition in flowchart

13
New cards

endless loop

Infinite loop is also called _____.

14
New cards

Infinite loop

The condition to end the loop is never met

15
New cards

Counters and Accumulators

Used to calculate subtotals, totals, and averages

16
New cards

Counter

Numeric variable used for counting

17
New cards

Accumulator

Numeric variable for accumulating (adding together) something

18
New cards

Initializing

Assigning beginning value

19
New cards

Updating (incrementing)

  • Adding a number to accumulator’s value

    • Number can be positive or negative

  • Done within the loop body

20
New cards

Priming read

Use to prime (prepare or set up) loop by performing first action prior to entering loop

21
New cards

Update read

Allows user to update value that controls loop’s condition

22
New cards

Arithmetic Assignment Operators

  • Used to abbreviate an assignment statement:

    • Containing an arithmetic operator

  • Format

    variableName = variableName arithmeticOperator value

  • Example

    • intAge = intAge + 1 can be abbreviated

      intAge += 1

23
New cards

For…Next statement

  • Used to code a counter-controlled loop

  • Processes instructions precise number of times

  • Condition tested before processing (pretest loop)

  • Must specify start value, end value, and step value

24
New cards

Start value and end value

provide looping range

25
New cards

Step value

increments or decrements counter

26
New cards

hexagon

For clause represented by a _____ in flowchart

27
New cards

For…Next

Comparing the For…Next and Do…Loop Statements

  1. Either can be used to code counter-controlled loop

    • _____ is more convenient

  2. Declaration, initialization, update, and comparison

    • Handled by the For clause

28
New cards

Do…Loop

Comparing the For…Next and Do…Loop Statements

  1. Must declare and initialize the counter variables

  2. And update the counter variable

  3. Include the appropriate comparison in the Do clause

29
New cards

Initialized

Updated within loop

Counters and accumulators must be (2):

30
New cards

Nested repetition structure

Inner loop placed entirely within outer loop

31
New cards

Inner loop

is referred to as nested loop

32
New cards

Refresh method

  • Ensures that computer processes any previous lines of code that affect interface appearance

  • Syntax:

    • Me.Refresh()

      • Me refers to current form

33
New cards

Sleep method

  • Delays program execution

  • Syntax:

    • System.Threading.Thread.Sleep(milliseconds)

      • Millisecond: 1/1000 of second

34
New cards

List box

Displays list of choices from which user can select zero or more choices

35
New cards

SelectionMode property

Controls number of choices that can be selected

36
New cards

ListBox tool

Used to add list box to interface

37
New cards

3 to 8

List box can be made any size you want

Windows standard: _____ to _____ choices

38
New cards

Collection

Group of objects treated as one unit

39
New cards

Items collection

Refers to group of items in list box

40
New cards

Index

  • Unique number that identifies each item in collection

  • First item has _____ of zero

41
New cards

Items collection’s Add method or Items.Add method

  • Used to add item to list box

  • Usually entered in form’s Load event procedure

42
New cards

Sorted property

List box

  • Determines order of displayed items

  • If True,

    • newly added item is placed in its proper position

  • If False

    • newly added item is placed at end of list

  • Uses dictionary sort order

43
New cards

SelectedItem property

  • Contains value of selected item

  • Contains empty string when no item is selected

44
New cards

SelectedIndex property

  • Contains value of selected item’s index

  • Contains -1 when no item is selected

45
New cards

Default list box item

  • Appears when application is first loaded

  • Chosen by setting either SelectedItem or SelectedIndex property

46
New cards

SelectedValueChanged event,
SelectedIndexChanged event

  • Occur when user or code statement selects item in list box

  • Can use these events to process instructions when selection is made