Intro. to Programming Ch. 4 practice test

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

You have just started working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudocode. In the following pseudocode, what will be the value of sum after the code is run? Declarations num count = 0 num sum = 0 while count < 3 for X = 1 to 2 step 1 sum = sum + X endfor count = count + 1 endwhile

9

When you do not know when you write the program whether the loop will be executed two times, 200 times, or not at all you should use a definite loop.

False

Many programs are not run at the command prompt in a text environment, but are run using a ____, which allows users to interact with a program in a graphical environment.

GUI

Which of the following is NOT a mistake that programmers commonly make with loops?

Including statements outside the loop that belong inside the loop

You have just started working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudocode. The following pseudocode is not working properly. The message should display 10 times. This is not working because the programmer made which common loop mistake? for count = 1 to 10 output "Hello" endfor

Neglecting to alter the loop control variable

You have just started working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudocode. The following pseudocode is not working properly. The message should display five times. This is not working because the programmer made which common loop mistake? Declarations num count string message = "OK" while count < 5 output message count = count + 1 endwhile

Neglecting to initialize the loop control variable.

A(n) ____ is a variable that you use to gather or accumulate values.

accumulator

The ____ is the location on your computer screen at which you type entries to communicate with the computer's operating system using text.

command prompt

A(n) ____ is any numeric variable you use to count the number of times an event has occurred.

counter

Some loops are controlled by reducing, or ____.

decrementing

A loop for which the number of iterations is predetermined is called a(n) ____ loop, or counted loop.

definite

Reports that include some output for every input record are ____ reports.

detail

With a ____ loop, the loop body executes once before the loop-controlling condition is tested.

do-while

Programmers use the term "____" to describe programs that are well designed and easy to understand and maintain.

elegant

To indicate end-of-file, use the ____ indicator.

eof

The ____ statement uses a loop control variable and provides you with three actions automatically in one compact statement: initialization, evaluation and incrementation.

for

Commonly, you control a loop's repetitions by using either a counter or a ____ value.

sentinel

You can use any of the ____ comparison operators to control a loop.

six

A(n) ____ value is a number you use to increase a loop control variable on each pass through a loop.

step

Business reports that list no individual detail records, just totals, are called ____ reports.

summary

Just as with a selection, the Boolean comparison that controls a while loop must compare same-type values.

true

Often, the value of a loop control variable is not altered by arithmetic, but instead is altered by ____.

user input

Loops are frequently used to ____ data; that is, to make sure values fall within an acceptable or reasonable range.

validate

As long as a Boolean expression remains true, a ____ loop's body executes.

while

Every high-level computer programming language contains a ____ statement that you can use to code any loop, including both indefinite and definite loops.

while

Many programmers prefer starting their counted loops with a variable containing a(n) ____ value.

0

The decision that controls every loop is always based on a ____ expression.

Boolean

All programming languages assign 0 to a variable you fail to initialize explicitly.

False

An accumulator is the same thing as a counter that you use to count loop iterations.

False

If a data item is valid, you can assume that it is also correct.

False

Once your logic enters the body of a structured loop, you can exit the loop body early if you program it correctly.

False

The number of times a loop executes should always depend on a constant.

False

You have just started working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudocode. The following pseudocode is not working properly. The message should display 10 times. What needs to be changed? for count = 0 to 10 output "I love programming!" endfor

The for statement should be:for count = 0 to 9 step 1

It is always a mistake to fail to initialize a loop's control variable.

True

Most languages provide a built-in way to check whether a value that is entered is numeric or not.

True

While making decisions is what makes computers seem intelligent, it's looping that makes computer programming both efficient and worthwhile.

True

When a loop control variable is numeric, its value is often altered by ____ it, or adding to it.

incrementing

When you write a loop, you must control the number of repetitions it performs; if you do not, you run the risk of creating a(n) ____ loop.

infinite

When one loop is nested within another, the loop that is contained is the ____ loop.

inner

A ____ is the structure that repeats actions while some condition continues.

loop

When you use a ____ within a computer program, you can write one set of instructions that operates on multiple, separate sets of data.

loop

Program logic gets more complicated when you must use loops within loops, creating ____ loops.

nested

You have just started working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudocode. The following pseudocode is not working properly. The message should display five times. What needs to be changed? Declarations string message = "OK" while count < 5 output message count = count + 1 endwhile

num count = 0 should be added to the Declarations

When one loop is nested within another, the containing loop is the ____ loop.

outer

A value such as "Y" or "N" that a user must supply to stop a loop is called a(n) ____ value.

sentinel


Ensembles d'études connexes

ECON 2302 Final Micro Tanter Tarleton

View Set

CMIS 342 Exam 3 possible questions

View Set

Chapter 42: Nursing Management: Lower Gastrointestinal Problems My Nursing Test Banks

View Set

Saunders reproductive system review

View Set