While Loop

While Loop

10th Grade

5 Qs

quiz-placeholder

Similar activities

Python Loops Quiz (for loop and while loop)

Python Loops Quiz (for loop and while loop)

10th Grade

10 Qs

Loops

Loops

10th - 12th Grade

6 Qs

Struktur Perulangan C++

Struktur Perulangan C++

10th Grade

10 Qs

Quizizz Evaluasi Bab 11

Quizizz Evaluasi Bab 11

10th Grade

10 Qs

cpp04_loop

cpp04_loop

6th Grade - University

10 Qs

VB Quiz

VB Quiz

5th Grade - University

10 Qs

Python Condition Controlled Iteration

Python Condition Controlled Iteration

10th Grade

10 Qs

Java Quiz 1: Introduction

Java Quiz 1: Introduction

6th - 12th Grade

10 Qs

While Loop

While Loop

Assessment

Quiz

Computers

10th Grade

Hard

Created by

Umar Golamaully

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main purpose of a 'While' loop in programming?

To repeat a set of instructions a specific number of times

To repeat a set of instructions as long as a condition is true

To declare variables

To print text on the screen

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If the condition in a 'While' loop is initially false, how many times will the loop execute?

1 time

0 times

Infinite times

Depends on the code inside the loop

Answer explanation

The condition for 'While' loop is checked at the start. If at the very start of the loop, the condition evaluates to False, then the code inside the loop will not be executed at all.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In VB, what keyword is used to mark the end of a 'While' loop?

End While

Next

End Loop

Loop Until

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will be the output of the following VB code if X is set to 1 (X = 1) before the start of the 'While' loop?

Hello

Hello

Hello

Hello

Hello

Hello

Infinite Loop

Answer explanation

X is initially 1. (X = 1)

As long as the condition X <= 3 in the While loop is true, the word "Hello" will be printed on screen.

X is incremented by 1 (X = X + 1) to prevent infinite loop.

So, "Hello" will be printed 3 times (when X = 1, X = 2 and X = 3).

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Identify the error in this VB code.

The 'While' keyword is incorrect

The condition i >= 1 is incorrect

The loop does not update the value of variable i, causing an infinite loop

The loop will not execute at all

Answer explanation

The value of i is initially 10.

The While keyword is correctly written.

The condition of the While loop is true (since i >= 1).

The loop will be executed and the value of i will be printed on screen.

But notice that the the value of i is not decremented before the 'While' loop ends.

This causes i to remain at value 10 each time the loop executes, causing infinite loop.