Chapter 5.2

Ace your homework & exams now with Quizwiz!

What usually needs to happen before the test is done at the beginning of a Pretest Loop?

Some steps need to be performed to make sure the loop executes at least once.

What conventions should be adhered to when writing a Do-While loop?

The Do and While clauses should be aligned. The statements inside the body of the loop should be indented.

In the general format for a While loop, what conventions should be followed?

The While and End While clauses should be aligned. The statements in the body of the loop should be indented.

What are the statements between the While and End While clauses of a While loop referred to as?

The body of the loop

In a flowchart, what does the diamond symbol in a While loop represent?

The condition that is being tested for truth.

Can Modules be called from the statements in the body of a loop?

Yes

What kind of loop is a Do-Until loop?

A Posttest loop

What are the two parts of a While loop?

1.) A condition is tested for a true or false value. 2.) A statement or set of statements repeats as long as the condition is true.

In the general format of a While loop, what is the condition?

A Boolean expression

A While loop is referred to as a Pretest Loop. What is the Do-While loop referred to as?

A Posttest loop

The While loop is known as what kind of loop?

A Pretest Loop

How would you define a Posttest Loop?

A loop that performs an iteration before testing its condition.

How would you define a Pretest Loop?

A loop that tests its condition BEFORE performing an iteration.

What is a loop called that has no way of stopping?

An infinite loop

Why don't all programming languages provide a Do-Until loop?

Because you can write a Do-While loop that is logically equivalent to a Do-Until loop.

What do While and Do-While loops do?

Cause a statement or set of statements to repeat as LONG as a condition is true.

What does a Do-Until loop do?

Causes a statement or set of statements to repeat UNTIL a condition is true.

What is the general Pseudocode structure for a Do-Until loop?

Do statement statement etc. Until condition

What is the general Pseudocode structure for a Do-While loop?

Do statement statement etc. While condition

When would you want to use a While loop?

To repeat a task as long as a condition is true. It is ideal in situations where the condition MIGHT be false to begin with.

When would you want to use a Do-While loop?

To repeat a task as long as a condition is true. It is ideal in situations where you want the iteration to be performed at LEAST once.

What is the general Pseudocode structure for a While loop?

While condition statement statement etc. End While


Related study sets

Chapter 6 Mood Disorders and Suicide

View Set

Social Studies Chapter 4: The Virginia Colonies (Lesson 2)

View Set