Chapter 5 - CS123

what is the initial statement in the following for loop?

int i;
for (I = 1; i<20; I++)
cout << "Hello World";
cout << "!" << endl;

i = 1

a loop that continues to execute endlessly is called a(n) ____ loop.

infinite

What executes immediately after a continue statement in a while and do-while loop?

loop-continue test

____ loops are called posttest loops.

do while

In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read. ( t or f )

false

The control statements in the for loop include the initial statement, loop condition, and update statement. ( t or f )

true

In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).

looping

Which of the following loops is guaranteed to execute at least once?

do while loop

Which of the following loops does not have an entry condition?

A do while loop

Which of the following is a repetition structure in C++?

do while

The statement in the body of a while loop acts as a decision maker. ( t or f )

false

The ____ statement can be used to eliminate the use of certain (flag) variables.

break

When a continue statement is executed in a ____, the update statement always executes.

for loop

What is the value of x after the following statements execute? int x = 5;
int y = 30;
do
x = x * 2;
while (x < y);

40

Assume that all variables are properly declared. The following for loop executes 20 times.
for (i = 0; i <= 20; i++)
cout << ( t or f )

false

Which executes first in a do...while loop?

the statement

Suppose j,sum,and num are int variables, and the input is 26 34 61 4 -1.Whatisthe output of the code?

sum = 0;
cin >> num;
for (int j = 1; j <= 4; j++)
{
sum = sum + num;
cin >> num;
}
cout << sum << endl;

125

What is the output of the following C++ code?
count = 1;
num = 25;
while (count < 25)
{
num = num - 1;
count++;
}
cout << count << " " << num << endl;

25 1

What is the output of the following loop?
count = 5;
cout << 'St';
do
{
cout << 'o';
count--; }
while (count <= 5);

this is an infinite loop

Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5.

n = 1;
while (n < 5)
{
n++;
cout << n << " ";
} ( t or f )

True

Which of the following statements generates a random number between 0 and 50?

srand(time(0)); num = rand() % 50;

The following while loop terminates when j > 20.
j = 0;
while (j < 20)
j++; ( t or f )

false

What is the output of the following C++ code?

int j;
for (j = 10; j <= 10; j++)
cout << j << " ";
cout << j << endl;

11 11

What is the output of the following C++ code?
num = 10;
while (num > 10)
num = num - 2;
cout << num << endl;

10

In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.( t or f)

True

Chapter 5 - CS123 - Subjecto.com

Chapter 5 – CS123

Your page rank:

Total word count: 572
Pages: 2

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

what is the initial statement in the following for loop?

int i;
for (I = 1; i<20; I++)
cout << "Hello World";
cout << "!" << endl;

i = 1

a loop that continues to execute endlessly is called a(n) ____ loop.

infinite

What executes immediately after a continue statement in a while and do-while loop?

loop-continue test

____ loops are called posttest loops.

do while

In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read. ( t or f )

false

The control statements in the for loop include the initial statement, loop condition, and update statement. ( t or f )

true

In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).

looping

Which of the following loops is guaranteed to execute at least once?

do while loop

Which of the following loops does not have an entry condition?

A do while loop

Which of the following is a repetition structure in C++?

do while

The statement in the body of a while loop acts as a decision maker. ( t or f )

false

The ____ statement can be used to eliminate the use of certain (flag) variables.

break

When a continue statement is executed in a ____, the update statement always executes.

for loop

What is the value of x after the following statements execute? int x = 5;
int y = 30;
do
x = x * 2;
while (x < y);

40

Assume that all variables are properly declared. The following for loop executes 20 times.
for (i = 0; i <= 20; i++)
cout << ( t or f )

false

Which executes first in a do…while loop?

the statement

Suppose j,sum,and num are int variables, and the input is 26 34 61 4 -1.Whatisthe output of the code?

sum = 0;
cin >> num;
for (int j = 1; j <= 4; j++)
{
sum = sum + num;
cin >> num;
}
cout << sum << endl;

125

What is the output of the following C++ code?
count = 1;
num = 25;
while (count < 25)
{
num = num – 1;
count++;
}
cout << count << " " << num << endl;

25 1

What is the output of the following loop?
count = 5;
cout << ‘St’;
do
{
cout << ‘o’;
count–; }
while (count <= 5);

this is an infinite loop

Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5.

n = 1;
while (n < 5)
{
n++;
cout << n << " ";
} ( t or f )

True

Which of the following statements generates a random number between 0 and 50?

srand(time(0)); num = rand() % 50;

The following while loop terminates when j > 20.
j = 0;
while (j < 20)
j++; ( t or f )

false

What is the output of the following C++ code?

int j;
for (j = 10; j <= 10; j++)
cout << j << " ";
cout << j << endl;

11 11

What is the output of the following C++ code?
num = 10;
while (num > 10)
num = num – 2;
cout << num << endl;

10

In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.( t or f)

True

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending