While Loop

Quiz
•
Computers
•
10th Grade
•
Hard
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
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
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.
Similar Resources on Wayground
10 questions
CS 50 Terminology

Quiz
•
6th - 10th Grade
10 questions
Python Basics

Quiz
•
8th - 10th Grade
10 questions
Dasar Pemrograman C++

Quiz
•
10th Grade
10 questions
Pseudocode - OCR ERL

Quiz
•
9th - 12th Grade
7 questions
Computer Science Essentials Vocabulary

Quiz
•
9th - 12th Grade
10 questions
Python beginners quiz

Quiz
•
9th - 10th Grade
9 questions
Programming Basics

Quiz
•
10th Grade
10 questions
Flow Charts

Quiz
•
1st - 10th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
1.2 OSI & TCP IP Models Quiz

Quiz
•
10th Grade
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
20 questions
Hardware vs. Software Quiz

Quiz
•
7th - 10th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade