wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz 1 in CC 102

Total questions: 30

Worksheet time: 21mins

Name
Class
Date
1.

It is a value where the loop control variable will be compared to.

a)

Loop Control Variable

b)

Sentinel Value

c)

Boolean Value

d)

Loop update

2.

It is a loop that never stops.

a)

empty loop

b)

infinite loop

c)

for loop

d)

while loop

3.

It is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.

a)

empty loop

b)

infinite loop

c)

for loop

d)

while loop

4.

In this type of loop, the initialization of the loop control variable is typed before the structure of the loop. The loop update on the other hand is placed inside the loop body.

a)

empty loop

b)

infinite loop

c)

for loop

d)

while loop

5.

In this type of loop, the comparison happens at the end of the do while loop so the body of the loop is executed at least once even if the comparison expression evaluates to false,

a)

do while loop

b)

infinite loop

c)

for loop

d)

while loop

6.

A loop that will not do anything.

a)

do while loop

b)

infinite loop

c)

empty loop

d)

while loop

7.

It holds the value that will be compared to the limit of the loop.

a)

do while loop

b)

loop udate

c)

sentinel value

d)

loop control variable

8.

Operator that subtracts 1 to its operand.

a)

increment

b)

assignment

c)

decrement

d)

comparison

9.

Operator that adds 1 to its operand.

a)

increment

b)

assignment

c)

decrement

d)

comparison

10.

A loop update using ________will continue to do the iteration until such time that the user of the program tells the program to stop the execution of the looping process. 

a)

increment

b)

prompt

c)

decrement

d)

comparison

11.

TRUE OR FALSE. The loop update using prompt is a process where there will be a question prompting the user if he wants to continue or stop executing the loop.

a)

TRUE

b)

FALSE

12.

TRUE OR FALSE. In for loop, the initialization of the loop control variable is executed first, and only once.

a)

TRUE

b)

FALSE

13.

TRUE OR FALSE. Increment and decrement are only for adding or subtracting 1 from the current value of the loop control variable

a)

TRUE

b)

FALSE

14.

TRUE OR FALSE. If you are using prefix form, the increment or decrement will be done after evaluating the expression.

a)

TRUE

b)

FALSE

15.

TRUE OR FALSE. If you are using postfix form, the increment or decrement will be done before the complete expression is evaluated.

a)

TRUE

b)

FALSE

16.

TRUE OR FALSE. The sentinel value is set to decide if the loop will continue or stop based on the result of the comparison

a)

TRUE

b)

FALSE

17.

TRUE OR FALSE. The result of the comparison is always a Boolean value, that is, true or a false.

a)

TRUE

b)

FALSE

18.

TRUE OR FALSE. C++ provides a structure which will help you do repetitive tasks without typing them over and over again. It is called the repetition structure or looping.

a)

TRUE

b)

FALSE

19.

TRUE OR FALSE. The loop control variable should last be initialized before it can be used in the program

a)

TRUE

b)

FALSE

20.

TRUE OR FALSE. The loop update can change the value by incrementing or decrementing. 

a)

TRUE

b)

FALSE

21.

What is the updated value of a?

where

a=10;

a-=2;

a++;

(a)  

22.

What is the updated value of a?

where:

y=5;

a=2+y;

y-=2;

++a;

(a)  

23.

What is the updated value of y?

where:

y=3;

a=2+y;

y-=2;

++y;

(a)  

24.

What is the updated value of x?

where:

x=1;

y=1;

x=x+5;

x=x+y;



(a)  

25.

What is the updated value of y?

where:

x=3;

y=10;

x=x+5;

y=x+y;



(a)  

26.

What is the updated value of y?

where:

x=2;

y=5;

x=x+y;

y=x*y;



(a)  

27.

What is the updated value of y?

where:

x=25;

y=5;

x=x/y;

y=x*y;



(a)  

28.

What is the updated value of y?

where:

x=5;

y=x;

y= x * y;



(a)  

29.

What is the output of this code?

for(x=1;x<4;x++)

{

cout<<x;

}



(a)  

30.

What is the output of this code?

int a=5;

while(a>1)

{

cout<<a;

a--;

}

(a)