×
13 Lessons

Model 2

In this module, we continue our journey into programming by introducing one of the earliest and most widely used beginner-friendly programming languages: QBasic. This curriculum is designed to help participants understand the fundamental principles of programming using QBasic as a foundation. By the end of this module, you will be able to write, run, and debug simple programs while also learning the logical thinking skills necessary to advance into modern programming languages.

19 Lessons

In this lesson, students learn about the WHILE...WEND LOOP in QBASIC, a control structure used to repeat a block of code as long as a specified condition remains true.

The lesson provides a practical introduction to how a WHILE loop works by using variables, conditions, PRINT statements and increment operations.

Students will work through two practical QBASIC examples to understand how the condition controls the repetition of the program.

PRACTICAL EXAMPLE ONE

DIM Ama AS INTEGER
Ama = 1
CLS

WHILE Ama <> 10
PRINT Ama; "2="; Ama2
Ama = Ama + 1
WEND

This example demonstrates how the program repeatedly displays the value of Ama and its multiplication by 2 while the condition Ama <> 10 remains true.

PRACTICAL EXAMPLE TWO

DIM Ama AS INTEGER
Ama = 1
CLS

WHILE Ama <> 4
PRINT "Ama"
Ama = Ama + 1
WEND

The second example demonstrates another practical use of the WHILE...WEND structure and helps students understand how changing the condition affects the repetition of the loop.

LEARNING OBJECTIVES

By the end of Lesson 19, students should be able to:

Define a WHILE LOOP in programming.

Explain the purpose of WHILE...WEND in QBASIC.

Create a simple WHILE...WEND program.

Declare an INTEGER variable using DIM.

Assign an initial value to a variable.

Create a condition for a WHILE loop.

Use PRINT to display program information.

Increase a variable during program execution.

Explain the function of WEND.

Trace the execution of a WHILE...WEND program.

Determine when a WHILE loop stops.

Develop simple practical programs using WHILE...WEND.

Students are encouraged to practise both examples independently and observe how the condition controls the repetition of the program.