
While Loop
Authored by Umar Golamaully
Computers
10th Grade

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Emerging technologies
Quiz
•
6th Grade - University
10 questions
ICT SKILLS
Quiz
•
9th - 10th Grade
10 questions
Database Quiz - St. Boniface
Quiz
•
10th Grade
9 questions
Internet Protocols
Quiz
•
10th - 11th Grade
10 questions
Microsoft Teams
Quiz
•
KG - 12th Grade
10 questions
Cyber Security
Quiz
•
1st - 10th Grade
10 questions
Python Alternating Turns
Quiz
•
7th - 12th Grade
10 questions
Lesson 01 Unit 1 Excel 2019/365 MOAC
Quiz
•
9th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade