• Home
  • Textbooks
  • Microsoft Visual C# 2017: An Introduction to Object-Oriented Programming
  • Looping

Microsoft Visual C# 2017: An Introduction to Object-Oriented Programming

Joyce Farrell

Chapter 5

Looping - all with Video Answers

Educators


Chapter Questions

Problem 1

A structure that allows repeated execution of a block of statements is a(n) ___________
a. sequence
c. array
b. selection
d. loop

Check back soon!
01:26

Problem 2

The body of a while loop can consist of ___________
a. a single statement
c. either a or b
b. a block of statements within curly
d. neither a nor b braces

Prashant Bana
Prashant Bana
Numerade Educator
00:45

Problem 3

A loop that never ends is called an ___________ loop.
a. indefinite
c. infinite
b. interminable
d. intermediate

Kayla Day
Kayla Day
Numerade Educator

Problem 4

Which of the following is not required of a loop control variable in a correctly working loop?
a. It is reset to its initial value before the loop ends.
b. It is initialized before the loop starts.
c. It is tested.
d. It is altered in the loop body.

Check back soon!
01:26

Problem 5

A while loop with an empty body contains no ___________
a. statements
b. loop control variable
c. curly braces
d. test within the parentheses of the while statement

Prashant Bana
Prashant Bana
Numerade Educator

Problem 6

A loop for which you do not know the number of iterations when you write it is a(n) ___________
a. indefinite loop
c. counted loop
b. definite loop
d. for loop

Check back soon!

Problem 7

What is the major advantage of using a for loop instead of a while loop?
a. With a for loop, it is impossible to create an infinite loop.
b. The loop control variable is initialized, tested, and altered all in one place.
c. It is the only way to achieve an indefinite loop.
d. Unlike with a while loop, the execution of multiple statements can depend on the test condition.

Check back soon!

Problem 8

A for loop statement must contain ___________
a. two semicolons
c. four dots
b. three commas
d. five pipes

Check back soon!
07:44

Problem 9

In a for statement, the section before the first semicolon executes ___________
a. once
b. once prior to each loop iteration
c. once after each loop iteration
d. one less time than the initial loop control variable value

Samuel Goyette
Samuel Goyette
Numerade Educator

Problem 10

The three sections of the for loop are most commonly used for ___________ the loop control variable.
a. testing, outputting, and incrementing
b. initializing, testing, and incrementing
c. incrementing, selecting, and testing
d. initializing, converting, and outputting

Check back soon!

Problem 11

Which loop is most convenient to use if the loop body must always execute at least once?
a. a while loop
c. a do loop
b. a for loop
d. an if loop

Check back soon!

Problem 12

The loop control variable is checked at the bottom of which kind of loop?
a. a while loop
c. a do loop
b. a for loop
d. all of the above

Check back soon!

Problem 13

A for loop is an example of $a(n)$ ___________ loop.
a. untested
c. posttest
b. pretest
d. infinite

Check back soon!

Problem 14

A while loop is an example of a(n) ___________ loop.
a. untested
c. posttest
b. pretest
d. infinite

Check back soon!

Problem 15

When a loop is placed within another loop, the loops are said to be ___________
a. infinite
c. overlapping
b. bubbled
d. nested

Check back soon!

Problem 16

What does the following code segment display?
```
a = 1;
while (a < 5);
{
Write("{0} ", a);
++a;
}
```
a. 1234
c. 4
b. 1
d. nothing

Check back soon!

Problem 17

What is the output of the following code segment?
```
s=1;
while(s < 4)
++s;
Write("{0} ", s);
```
a. 1
c. 1234
b. 4
d. 234

Check back soon!
View

Problem 18

What is the output of the following code segment?
```
j = 5;
while(j> 0)
{
Write("{0} ", j);
j--;
}
```
a. 0
c. 54321
b. 5
d. 543210

Gio Maya
Gio Maya
Numerade Educator

Problem 19

What does the following code segment display?
for ( $f=0 ; f<3 ;++f$ ); Write("\{0\} ", f);
a. 0
c. 3
b. 012
d. nothing

Check back soon!

Problem 20

What does the following code segment display?
for $(t=0 ; t<3 ;++t)$ Write (" $\{0\} ~ ", t)$;
a. 0
c. 012
b. 01
d. 0123

Check back soon!