Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Flow of Control in C++ ( Conditional statements)

Total questions: 17

Worksheet time: 9mins

Name
Class
Date
1.

Choose the multiway branch statement from the following.

a)

if

b)

for

c)

if ... else

d)

switch

2.

Identify the exit control loop from the following.

a)

for

b)

while

c)

do..while

d)

if..else

3.

This statement is used to terminate the execution of the loop

a)

break

b)

jump

c)

goto

d)

continue

4.

Predict the output.

a)

320 11 330

b)

320 10 330

c)

330 11 320

5.

Predict the output

a)

5

b)

Empty Loop

c)

No Answer

d)

1234

6.

Read the program carefully and give your output

a)

Welcome Child!!!

b)
c)

Error

d)

Welcome Child!!! Welcome Child!!!Welcome Child!!!

7.

Identify the iteration statments from the following:

a)

for

b)

switch

c)

if

d)

while

e)

do while

8.

int i=1;

while(i<5)

{ cout<<i;i++; }

How many times the above loop will be executed?

a)

5

b)

1

c)

Will not be executed at all

d)

4

9.

int i=1;

while(i<5)

{

i=1;

cout<<i;

i++;

}

Predict the output.

a)

Infinite loop

b)

1 2 1 2 1 2

c)

5 times

d)

Run time Error

10.

Nesting of switch statment is allowed.

a)

True

b)

False

11.

What is currect syntax of for loop?

a)

for(initialization;condition; increment/decrement)

b)

for(increment/decrement; initialization; condition)

c)

for(initialization, condition, increment/decrement

d)

None of These

12.

The statement i++; is equivalent to

a)

i = i + i;

b)

i = i + 1;

c)

i = i - 1;

d)

i --;

13.

Which looping process is best used when the number of iterations is known?

a)

for

b)

while

c)

do-while

d)

all looping processes require that the iterations be known

14.

Make this code stop looping once you get the right answer:


string answer;

bool hasGuessed = false;


while(true) {


cin>> answer;


if (answer == “the right answer”){

__________

}


}

a)

hasGuessed == false

b)

hasGussed == true

c)

hasGuessed = true;

d)

hasGuessed = false;

15.

Make this code loop three times:


in tries= 0;


while(_________ ) {

cin>> “Looping!”;

tries++;


}

a)

tries < 3

b)

answer == 3

c)

tries > 0

d)

tries < 0

16.

Which of these statements stops a while loop?

a)

stop;

b)

break;

c)

loop pause;

d)

do { }

17.

Fill in the blank with the right symbol to make this code print Tacos 4 times


int tacos = 4;


while(tacos (a)   0){

cout<<“Tacos”<<endl;


tacos - - ;

}