CISP300 Chapter 5

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which loop is specifically designed to initialize, test, and increment a counter variable?

For

Which loop statement does not contain an increment statement but automatically increments the counter at the end of each iteration?

For

This is a design tool that describes the input, processing, and output of a function.

IPO chart

Which pair of loops causes a statement or set of statements to repeat as long as a condition is true?

While and Do-While

True/False: The While loop gets its name from the way it works: While a condition is false, do some task.

False

The While and For loops are considered pretest loops because they test the condition before processing the statement(s) in the loop body.

True

The While loop is known as a pretest loop, which means it tests its condition before performing an iteration.

True

A condition-controlled loop can be used to iterate the body of the loop a specific number of times.

True

The For loop is a _____ type of loop.

pretest

The statements that appear between the While and the End While clauses are called the ________.

Body of the loop

Which loop repeats a statement or set of statements as long as the Boolean expression is false?

Do-Until

Which of these are posttest loops?

Do-While and Do-Until

A posttest loop does not perform any iteration if the Boolean expression is false to begin with.

False

How many times will the following loop iterate? Set k = 1 While k > 5 Display k End While

No iterations

A decision structure can be nested inside another decision structure.

True

The conditions that control a loop repetition are Boolean expressions.

True

A(n) ________ variable keeps a running total.

accumulator

While loop

gets its name from the way it works: While a condition is true, do some task. The loop has two parts: (1) a condition is tested for a true or false value (2) a statement or set of statements that is repeated as long as the condition is true. The while loop is known as a pretest loop.

A(n) ___________ loop has no way of ending and repeats until the program is interrupted.

infinite

The Do-While loop is a ______ type of loop.

posttest

This is an example of a data type conversion function.

toReal

counted loop

A loop for which the number of repetitions is a predetermined value.

definite loop

A loop for which the number of repetitions is a predetermined value.

indefinite loop

A loop for which you cannot predetermine the number of executions.

nested loop

A loop structure within another loop structure; nesting loops are loops within loops. See also inner loop and outer loop.

outer loop

A loop that contains a nested, inner loop.

inner loop

A loop that contains a nested, outer loop.

step value

A number you use to increase a loop control variable on each pass through a loop

counter

A numeric variable you use to count the number of times an event has occurred.

for statement

A statement that can be used to code definite loops. It contains a loop control variable that it automatically initializes, evaluates, and increments. Also called a for loop.

loop

A structure that repeats actions while a condition continues also known as a repetition structure.

loop control variable

A variable that determines whether a loop will continue. The loop control variable is initialized before entering the loop.

accumulator

A variable that you use to gather or accumulate values.

This type of of function returns either true or false.

Boolean

What type of loop uses a Boolean expression to control the number of times that it repeats a statement or set of statements?

Condition-controlled

The following is an example of what type of loop? For k = 7 To maxValue

Count-controlled

A program can be made of only one type of control structure. You cannot combine structures.

False

A single alternative decision structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.

False

In a For loop, the programmer should know the exact number of iterations the loop must perform before writing the code.

False

In the For statement, you can only use positive integers as step values.

False

How many times will the following loop iterate? Set k = 1 While k < = 5 Display k End While

Infinite

How many times will the following loop iterate? Set k = 1 Do Display k Set k = k + 1 Until k > 1

One

Which structure causes a statement or set of statements to execute repeatedly?

Repetition

This statement causes a function to end and sends a value back to the part of the program that called the function.

Return

The ________ represents a special value that marks the end of a list of values.

Sentinel

How many times will the following loop iterate? For j = 1 To 5 Step 2 Display j End For

Three

In a count-controlled loop, the counter performs ________ action(s).

Three

incrementing

To change a variable by adding a constant value to it, frequently 1. Contrast with decrementing.

decrementing

To change a variable by decreasing it by a constant value, frequently 1. Contrast with incrementing.

validating data

To make sure data falls within acceptable ranges.

A While loop repeats infinitely when there is no statement inside the loop body that makes the test condition false.

True

A compound Boolean expression created with the AND operator is true only when both sub-expressions are true.

True

Modules can be called from statements in the body of any loop.

True

Infinite loop

a infinite loop continues to repeat until the program is interrupted. In most circumstances you should avoid writing infinite loops.

Do until loop

a loop that iterates as long as a condition is false, and then stops when the condition becomes true.

Do while loop

a posttest loop. This means it performs an iteration before testing its condition. The do-while loop always performs at least one iteration, even if its condition is false to begin with.

This term describes any mechanism that accepts input, performs some operation that cannot be seen on the input, and produces output.

black box

This part of a function definition is comprised of one or more statements that are executed when the function is called.

body

A ______ controlled loop uses a true/false condition to control the number of times that it repeats.

condition

Two board categories of loops

condition-controlled loops and count-controlled.

A _______ controlled loop repeats a specific number of times.

count

This part of a function definition specifies the data type of the value that the function returns.

header

Sentinel value

is a special value that marks the end of a list of values.

Each repetition of a loop is known as a(n) _____________.

iteration

This is a prewritten function that is built into a programming language.

library function

A ________ loop always executes at least once.

postest

The While loop is a ________ type of loop.

pretest

count control loop

repeats a specific number of time

A(n) ________ is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list.

sentinel

This is a string inside of a another string.

substring

This type of error occurs when you try to assign a value of one data type to a variable of another data type.

type mismatch error

condition control loop

use true/false condition to control the number of times that it repeats.


Ensembles d'études connexes

Computer Science JAVA -- Chapter 7

View Set

Chapter 1: Taking Charge of Your Health

View Set

Understanding business 8th edition, Business Management Mid-term (Study Guide Q&A), Business 101, Intro to Business Final Review, INTRODUCTION TO BUSINESS FINAL EXAM

View Set

APES Unit 5 Progress Check MCQ Review

View Set

Forensic Accounting Final Exam Study Guide

View Set

Organizational Behavior Final 2.0

View Set

Q/A Respiratory chapter 30 and 31

View Set