Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SLG IPC Week 4

Total questions: 12

Worksheet time: 15mins

Name
Class
Date
1.

Did you turn memes on?

a)

Yes, of course. Who could forget the memes?

b)

What memes? I don't remember seeing that option.

c)

I saw the option, but didn't turn them on.

d)

They're already on by default.

2.

What does default do in a switch statement?

a)

Executes code regardless if a case matches or not.

b)

Executes code in the event no case is matched.

c)

Exits from the switch construct.

d)

What's a switch statement?

3.

if (minutes > 1)

s = 's';

else

s = ' ';

Can be rewritten as?

a)

s =

minutes > 1 ? 's' : ' ';

b)

s =

if (minutes > 1)

's' : ' ';

c)

s =

minutes > 1 ? ' ' : 's';

d)

s = 's' : ' ';

4.

Pick the odd one out.

a)

While

b)

Do while

c)

For

d)

Switch

5.

What is the difference between a do while and a regular while loop?

4 lines
6.

Write an example of a for loop.

4 lines
7.

Which for loop uses a flag properly?

a)

for (int i = 0; i < 10 && done == 0; i++)

b)

for (int flag = 0; flag < 10; flag++)

c)

for (i = 0; flag == 0; i++)

d)

for (int i = 0; i < 10 && i == 0; i++)

8.

Why shouldn't you use break outside of a switch statement?

a)

Because my professor told me so.

b)

Because it violates the single-entry single-exit principle.

c)

Because it would give me an error.

d)

Because it can only be used in a switch statement.

9.

What class of construct does the flowchart represent?

(a)  

10.

What class of construct does this flowchart represent?

(a)  

11.

Do you remember how to write a switch statement? Write an example of one now.

For simplicity you can use placeholders like condition, constant, sequence.

4 lines
12.

What is an infinite loop and why is it bad?

4 lines