Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Repetition and Loops Quiz

Total questions: 55

Worksheet time: 43mins

Name
Class
Date
1.

What is the primary purpose of a loop in programming?

a)

To execute a block of code repeatedly

b)

To store data temporarily

c)

To manage memory allocation

d)

To create a user interface

2.

Which of the following is NOT a type of loop?

a)

For loop

b)

While loop

c)

Switch loop

d)

Do...While loop

3.

What does a counted loop require to function correctly?

a)

A string variable

b)

A user input

c)

A random number generator

d)

A counter variable

4.

In a for loop, what does STEP 1 signify?

a)

Resetting the counter

b)

Decrementing the counter

c)

Stopping the loop

d)

Incrementing the counter

5.

What is the output of the following loop:
For x = 0 TO 4 STEP 1
Display x

a)

0 1 2 3 4

b)

0 1 2 3 4 5

c)

1 2 3 4 5

d)

5 4 3 2 1

6.

What is a sentinel value?

a)

A value that indicates the end of a loop

b)

A value that starts a loop

c)

A random number

d)

A string input

7.

Which loop will execute at least once regardless of the condition?

a)

Do While loop

b)

While loop

c)

Counted loop

d)

For loop

8.

What is the correct syntax for a decrementing for loop?

a)

For x = 10 TO 0 STEP -1

b)

For x = 5 TO 0 STEP 1

c)

For x = 0 TO 10 STEP 1

d)

For x = 1 TO 5 STEP 2

9.

In a while loop, when does the loop stop executing?

a)

When the condition becomes false

b)

When the condition is true

c)

After a fixed number of iterations

d)

When the loop is manually stopped

10.

What will happen if the condition in a while loop is always true?

a)

The program will crash

b)

An infinite loop occurs

c)

The loop will execute once

d)

The loop will not execute

11.

What is the output of the following code:

For x = 1 TO 5 STEP 1

Display x

a)

5 4 3 2 1

b)

1 2 3 4 5 6

c)

0 1 2 3 4 5

d)

1 2 3 4 5

12.

Which of the following is a characteristic of a decrementing loop?

a)

It requires a user input

b)

It cannot be nested

c)

It counts downwards

d)

It counts upwards

13.

What is the purpose of the 'EndFor' statement?

a)

To indicate the end of a for loop

b)

To stop the program

c)

To declare a variable

d)

To initialize a loop

14.

In the context of loops, what does 'iteration' refer to?

a)

The condition of the loop

b)

The total number of loops

c)

A single execution of the loop

d)

The initialization of the loop

15.

What will the following code output:

FOR x= 1 TO 3 STEP 1

Display 'Hello'

a)

No output

b)

Hello

c)

Hello Hello

d)

Hello Hello Hello

16.

What is the main difference between a counted loop and a sentinel loop?

a)

Counted loops have a fixed number of iterations

b)

Sentinel loops do not require a counter

c)

Counted loops can only count up

d)

Sentinel loops are faster

17.

What is the output of the following code: For x = 5 TO 0 STEP -1 Display x?

a)

5 4 3 2 1 0 0

b)

5 4 3 2 1

c)

0 1 2 3 4 5

d)

5 4 3 2 1 0

18.

Which of the following statements is true about nested loops?

a)

A loop inside another loop

b)

Only one loop can exist in a program

c)

Nested loops cannot be counted

d)

They are less efficient than single loops

19.

What is the purpose of the 'Display' command in a loop?

a)

To output data to the screen

b)

To initialize a variable

c)

To stop the loop

d)

To create a new loop

20.

What will happen if you forget to update the counter in a loop?

a)

It may create an infinite loop

b)

The loop will run faster

c)

The loop will execute only once

d)

The program will terminate

21.

What is an algorithm?

a)

A programming language

b)

A sequence of steps to solve a problem

c)

A type of flowchart

d)

A software tool

22.

Which of the following is NOT a characteristic of an algorithm?

a)

It must have a defined input

b)

It must produce at least one output

c)

It must be infinite in execution

d)

It must be unambiguous

23.

What is the primary purpose of a flowchart?

a)

To write a program in a specific programming language

b)

To depict the logical steps of an algorithm graphically

c)

To replace algorithms completely

d)

To execute a program

24.

Which symbol represents a decision-making step in a flowchart?

a)

Rectangle

b)

Parallelogram

c)

Diamond

d)

Oval

25.

What does a parallelogram symbol represent in a flowchart?

a)

Process

b)

Input/Output

c)

Decision

d)

Connector

26.

In a flowchart, what do arrows indicate?

a)

Start or End of the program

b)

Decision-making steps

c)

The flow of logic

d)

Input and Output operations

27.

What does a rectangle symbolize in a flowchart?

a)

Input or Output

b)

Processing (arithmetic or data manipulation)

c)

Decision-making

d)

Start or Stop

28.

What is the general direction of flow in a flowchart?

a)

Left to Right

b)

Right to Left

c)

Top to Bottom

d)

Bottom to Top

29.

Which of the following is NOT an advantage of using an algorithm?

a)

It is dependent on a specific programming language

b)

It provides a step-wise representation of a solution

c)

It is easy to debug

d)

It follows a definite procedure

30.

What is the purpose of a connector in a flowchart?

a)

To indicate the beginning or end of a process

b)

To connect different parts of a flowchart without intersecting lines

c)

To perform calculations

d)

To represent input and output operations

31.

Why should you use a flowchart before writing a program?

a)

Because drawing is more fun than coding

b)

Because debugging a bad program is like finding a needle in a haystack

c)

Because computers refuse to run programs without flowcharts

d)

Because flowcharts can double as modern art

32.

What happens if you don’t follow a flowchart properly?

a)

The program might develop self-awareness and rebel

b)

You might create a loop that traps you in an infinite debugging cycle

c)

Nothing, it’s just a suggestion... right?

d)

Your computer will burst into flames

33.

Why is the decision symbol in a flowchart a diamond?

a)

Because making decisions is as hard as finding a real diamond

b)

Because round symbols rolled off the paper

c)

Because decisions are expensive like diamonds

d)

Because rectangles were already taken

34.

What should you do if your flowchart keeps looping infinitely?

a)

Call it a "feature" and market it as artificial intelligence

b)

Blame the computer and restart it

c)

Add a stop condition before your brain overheats

d)

Give up and become a professional artist instead

35.

What is the main advantage of a flowchart over written instructions?

a)

It makes you look super professional when explaining things

b)

It lets you use cool shapes instead of boring words

c)

It makes it easier to see where you totally messed up

d)

All of the above

36.

Draw a flowchart that calculates the area of a rectangle.

Instructions:

Your flowchart should take input for the length and width.

It should multiply these values to get the area.

Finally, it should display the result.

37.

Create a flowchart that determines if a number is even or odd.

Instructions:

The program should ask for a number.

If the number is divisible by 2, print "Even."

Otherwise, print "Odd."

OR

Draw a horse.

38.

Draw a celebrity

(extra points if we can guess who it is)

39.

What is the best anime/series/movie and why?

4 lines
40.

How much wood would a woodchuck chuck if a woodchuck could chuck wood?

4 lines
41.

Which of the following is NOT a basic control structure in programming?

a)

Sequence

b)

Selection

c)

Repetition

d)

Compilation

42.

A logical error occurs when:

a)

The program has syntax errors

b)

The program crashes upon execution

c)

The program runs but produces incorrect results

d)

The program runs infinitely

43.

Which of the following operators is used for comparing two values in pseudocode?

a)

=

b)

==

c)

!=

d)

Both == and !=

44.

In a sequence control structure, statements are executed:

a)

Based on user input

b)

One after the other, in order

c)

Only if a condition is met

d)

Repeatedly until a condition is false

45.

Given the following pseudocode:

Start

num = -5

If num > 0

Display "Positive"

Else

Display "Negative"

EndIf

End

What will be displayed?

a)

Positive

b)

Negative

c)

No output

d)

Error due to syntax

46.

A CASE statement is best used when:

a)

You need to test multiple values for a variable

b)

You want to loop through a set of instructions

c)

You need to choose between only two options

d)

You are performing arithmetic calculations

47.

How many times will the following loop execute?

Start

x = 1

While (x <= 5)

Display x

x = x + 1

EndWhile

End

a)

4 times

b)

5 times

c)

6 times

d)

Infinite times

48.

What will happen if the loop condition is incorrectly set, such as While (x > 0) without decrementing x inside the loop?

a)

The loop will run indefinitely

b)

The loop will execute only once

c)

The loop will not execute at all

d)

The program will produce an error

49.

Start

For i = 1 to 3

For j = 1 to 2

Display "*"

EndFor

EndFor

End

How many times will the * be displayed?

a)

3

b)

5

c)

6

d)

9

50.

Start

num = 10

While (num > 0)

Display num

num = num - 2

EndWhile

End

What will be the last number displayed?

a)

0

b)

2

c)

1

d)

-1

51.

Start

total = 0

For i = 1 to 3

total = total + i

EndFor

Display total

End

What will the output be?

a)

3

b)

6

c)

9

d)

10

52.

Start

pin = 0

While pin != 1234

Display "Enter PIN"

pin = get value

EndWhile

Display "Correct PIN entered"

End

What will the result be if we run this program?

a)

It will terminate once the correct PIN (1234) is entered

b)

It will run indefinitely

c)

It will never execute the loop

d)

It will display "Correct PIN entered" without user input

53.

A WHILE loop is preferable over a FOR loop when:

a)

The number of iterations is known in advance

b)

The loop should execute at least once

c)

The number of iterations is unknown and depends on a condition

d)

You are iterating over a fixed range of numbers

54.

Give me your best pickup line

4 lines
55.

What will be the output of the following nested condition?

num = 15

If (num > 10)

If (num < 20)

Display "Within Range"

Else

Display "Out of Range"

EndIf

Else

Display "Out of Range"

EndIf

a)

Within Range

b)

Out of Range

c)

Error in logic

d)

Nothing is displayed