Chapter 10 QB64 Programming Statements
Chapter 10 QB64 Programming Statements
QB64
Programming
Statements
Intro
QB64 helps us to work with several commands using various operators and
looping statements. These commands help us to write programs to solve various
complex problem.
14
Find the area of the rectangle
32
IF THEN ELSE Statement
IF condition THEN
True_Statement
ELSE
False_Statement
END IF
Relational Operators
These set of operators are used when you want to make a comparison between
any two values. It displays the result as true or false depending upon the value
given.
Action Operator
Less than <
Less than or equal to =< OR <=
Greater than >
Greater than or equal to >= OR =>
Equal to =
Not equal to <> OR ><
Challenge
Create a program to accept the age of the user, if the user age
bigger than 17 then display text “You are allowed to join the
driving test” otherwise/else “You are not allowed”
Challenge
Create a program to accept a number from the user.
If the number entered is bigger than 0 then it will display “This is
a positive number”, otherwise it will display “This is a negative
number”.
Challenge
Create a program to accept a number from the user.
If the number entered is an even number then it will display “This
is an even number”, otherwise it will display “This is an odd
number”.
Logical Operators
These are used for combining two or more conditions. These operators give a
single value, which is either true or false.
Action Operator
All condition should be true AND
Any one condition should be true OR
Negates the condition NOT
Example
Create a program to accept the age of the user. Let’s make an
example that only people who are older than 17 and not older
than 21 able to join the driving test.
Example
Create a program to accept the age of the user and a question
“Do you have an ID?”, if the user insert their age bigger than 17
or they have an ID then they are allowed to join the test
otherwise/else they are not allowed.
Example
Somehow if the age of the user is 20 they are not allowed to join
the test. We can use NOT operator here.
String Operators
Also called as concatenation operators. These ae used to combine 2 strings
together.
Example:
Pring “have a”+”nice day”
ELSEIF Statement
The ELSEIF statement allows you to execute a set of statements
if the previous condition is false. It is generally used when you
have multiple conditions in a program.
IF condition THEN
Statement
ELSEIF condition THEN
Statement
ELSEIF condition THEN
Statement
ELSE
Statement
END IF
Example
Create a program to accept the color of traffic light.
If the color entered is red, then it will display “You need to stop”
If the color entered is yellow, then it will display “You need to wait”
If the color entered is green, then it will display “ You can go”
Challenge!
Write a QB64 program to accept any city from the user and display
landmark of that city.
Example:
City Landmark
Jakarta Monas