Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CSNP-04103 Chapter 5 - Loops

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Select all C++ repetition flow control structures.

a)

Sequential

b)

While Loop

c)

If else

d)

For Loop

e)

Do - While

2.

In c++ the statement x++; is equivalent to:

a)

y = y + 1

b)

x = x * 1

c)

-x

d)

x = x + 1

3.

In C++ the statement countEmp +=1; is equal to:

a)

countEmp = 1;

b)

countEmp ==1;

c)

countEmp = countEmp + 1;

d)

None of the above.

4.

Counter controlled loops are useful when:

a)

You don't know the number of interactions in the loop in advance

b)

You know the number of interactions needed in the loop in advance

c)

You need to repeat something

d)

You need to make a selection

5.

In a loop what happens when the control variable is not properly updated?.

a)

You won't get the proper answer.

b)

Your program will not run.

c)

You may get an infinite loop.

d)

The parser will tell you.

6.

Which C++ flow control repetition structure has on its header the initialization, condition and increment?.

a)

Do While

b)

While Loop

c)

If Else

d)

For Loop

7.

The instruction setw(<number>) belongs to the library:

a)

<iosteam>

b)

<cmath>

c)

<string>

d)

<iomanip>

8.

Conditional (while - Do while) loops are mostly used when:

a)

You know in advance the number of interactions in the loop.

b)

You can't determine before the loop execution the number of interactions.

c)

When you need to increase a value.

d)

When you need to count values.

9.

What are the part of a conditional while loop:

a)

initialization, condition, increment

b)

initialization, selection , execute

c)

initialization, test condition, execution, update condition

d)

None of the above.

10.

The difference between a while and a do while is:

a)

Only the Do word.

b)

The Do while will execute at least once.

c)

The Do while will evaluate the condition first

d)

The Do While increment happens after the condition is tested.