0% found this document useful (0 votes)
3 views7 pages

Adobe Scan 23 Mar 2023

The document provides an introduction to QB64, an IDE for the QBASIC programming language, covering its character set, constants, variables, and key statements like PRINT and INPUT. It explains the rules of syntax in programming, the types of variables, and how to use various QB64 commands effectively. Additionally, it includes activities, a glossary, and exercises to reinforce learning about programming concepts in QB64.

Uploaded by

arunkumarb1962
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Adobe Scan 23 Mar 2023

The document provides an introduction to QB64, an IDE for the QBASIC programming language, covering its character set, constants, variables, and key statements like PRINT and INPUT. It explains the rules of syntax in programming, the types of variables, and how to use various QB64 commands effectively. Additionally, it includes activities, a glossary, and exercises to reinforce learning about programming concepts in QB64.

Uploaded by

arunkumarb1962
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

QB64-

9 Statements
LEARNING OBJECTIVES
SNAP RECAP
You will learn aboul:
1. What is QB64? character set, constants and variables in
of
the different components QB64
2. What are

the QB64 window?


QB64 statements such as:
PRINT, LET
of CLS and PRINT INPUT, REM
3. What is the
use

commands?

Introduction languages
French, etc., programming
such as English,
Similar to ordinary languages In fact, the application
of these rules
grammar and spelling.
also have rules of syntax, to be explicit, as it
stricter. This is
because a program has
is
in a programming language
the actions to be taken.
is a precise s t a t e m e n t of
written in QBASIC programming
which is used to compile programs
QB64 is an IDE consist of
language, the elements of QB64
other programming
language. Just like any the operators, and the statements. Let us
the variables,
the character set, the constants,
study about of these elements here.
some

Character Set
charactersand symbols. These can be digits,
QB64 commands are written using some

character set used in QB64 1S:


letters and special characters. The
numeric digits:0 123456789
letters: A-Z, a-z
<,?,. ". }. 1. 1.), ete.
special characters: !, @, #, S, %, , &, *, (, ), >,

108
Constants
such
hValues thatva
do not change during the execution of the
program.
Constant are

following types.
C o n s t a n

c a n
t s

of the
be
t of

T h e s e

NumericC o n s t a n t s C o n s t a n t s

NumericC
numeric
meric digit
digits, that is, integers or real numbers, and can either be positive
the
a r e

e. Numeric constants ts can be used in arithmetic calculations. They do not


T h e s e

o rnegative.
special
character.
ial charact example, 1234, 0.75, 11.45, -18, etc. are all valid
For
include any
whereas 56!, 2/3, OE3, "764", etc. are invalid numeric constants.
ncluic
numeric
c o n s t a n t s

S t r i n g C o n s t a n t s

include the letters, and also be combined with


of characters that
can
h e set
Thesea r e the
blank spaces and the special characters. String constants are always
The ric digits,
( "). For example, "Rahul", "123", "P_Q",
etc.
double quotes
dosed within
e n c l o s e d

references made in a program


used for comparISon and
C o n s t a n t s are generally
arithmetic
calculations.
not for the
and

Variables
named memory
location FACT FILE
a variable is a
In QB64. which may or may
not change
a value
that contains A variable The reserved word in
the e x e c u t i o n
of the program. is a
during a time.
However, a programming language
o n e value at fixed meaning
can hold only word and can word which has
cannot be a reserved
variable n a m e variable name known to programming
of 40 characters. A
have a maximum have language and cannot be
with a letter and can
should always begin no space. redefined by the programmer.
decimal point but with
letters, numbers,
These are:
Variables are of two types.

Numeric Variable and


can
include letters
variable
name of the
numeric values. The
t Stores only the beloW.
are given
neric digits only. A few examples Invalid Numerie Variable

Valid Numeric Variable


M.L=9
MG 8 A@ = 10
LS7=6

109
String Variable
It is used for
storing string values (character set within double quotes). The string
variables can be named
using letter and numeric digits followed by a 's sign. These
always start with a letter. A few examples are given below:
Valid String Variable Invalid String Variable
Var$ "Name" %GSV$ =""Name"
V56S="Name" G%S="Name"

ACTIVITY

Check whether the following variable names are valid or invalid.


String Variable Numeric Variable String Variable Numeric Variable
ClickS SGS5 ****** 3StartS ***********
C-36 *************

Rose3S Var2$ Name *********


Ch4 **********

PRINT Statement
PRINT statement is used for displaying a value, message or an output on the monitor.
There are various ways in which a PRINT statement can be used in
QB64.
PRINT
PRINT statement without anything is used to display a blank line. For
example, the
and the corresponding output to display a blank line is given in figures 9.1 and 9.2.
input

PRINT "text/message"
This statement prints a text/message on the monitor. The text should be
enclosed within
double quotes ( "). For example, the input and the
corresponding output to display
Hello World' is given in figures 9.1 and 9.2,
respectively.
PRINT <any number>
This statement prints a number. If a number is to be displayed, quotations are not
used. For example, the input and the corresponding output to display 10' is given in
figures 9.l and 9.2, respectively.

110
PRINT with Separators

list can be printed in one PRINT statement but a separator


lore than one expression
More
must be used.

A when used between the


Separator (G): It is similar to Tab key.
a comma
Comma
Comma Sepa command leaves a gap of one tab space.
values with one PRINT
NO Drinting
once. A semicolon
(;): It is similar to pressing Space bar key
Semicolon Separator with one print command
leaves a gap of one
two printing values
between
when used
space in figures 9.1 and
is shown
separators, the output
for the given input using
For example,
9.2, respectively.
Untated

Help
UiewSearch Run 0ptions he roll nher of lex
Tile 4It Untitledm
of olox (
on)is 1M
Thie he ght
APRNELLO
PRINT HELLO
is
3ERI
4PRINTThe roll nunber of Aiex
Cin cn)ii"
134
of nlex
sitNT Te
Jeight

Status
ooNS A toEO
various PRINT
9.2 Output
sereen for
PRINNT
Fig.
statements
various

Input
screenfor
Fig. 9.1 s t a t e m e n t s

number> numbers that are to


The text and
<any and umber. text
PRINT "text; message is used to separate
both
text
off the
One o
(,). One
the separators
s eparator

prints c o m m a

This sta
s t a t e m e n t

separated
by a
are

be d i s p l a y e d
from number.

ACTIVITY
that:
and height.
your age
p r o g r a m

and then prints


QB64
tthe
he nextline
next line,

Write a
small

name,
skips
s kips
school address
and your city.
command
nmands to print your
difference in
your

to see the
1.
1. Pri
Prints
PRINT with commas or vice versa
multiple semicolons
r

enlace
e p l a c e

Use
then

and

Run
it
3 t h e o u t p u t .
GLOSSARY

Character set It is a set of characters and symbols based on which QB64 commands are

written.
Constant It is a value that does not change during the execution of a program.
INPUT statement It is a statement used for accepting a value (text or numbers) from the
user at the time of program execution.
LET statement It is a statement uscd for assigning a value to a variable within a program
whose value may change during the execution of the p gram.

Numeric variable It is a variable that stores numeric values.


used for displaying a value, message or an output on the
PRINT statement It is a statement

monitor

program.
lt stands for remark and it adds
comments in a
REM

String variable It is a variable that stores strings.


within double quotes (" ").
String lt is an alpha-numeric value that is given
named memory location that
contains a value which may change during
Variable It is a

program execution.

be numeric digits, letters or special


1. The character set used in QB64
can
YOU ARE
HERE characters.
constants.
2. Constants can be numeric constants or string
blank line.
9 3. PRINT statement without anything
4. PRINT statements with
semicolon
is used
as a
to display
separator will leave
a

a space of one

tab in between. in between.


as a separator will leave
a gap of one space
5. PRINT statements with
comma
readability of a
enhance the
Remarks are non-executable
statements in a program which
6.
program code.

114
EXERCISE

which QB64 commands are true or false.


AState whether
semicolon are the two separators used with PRINT
on of a program. 1 Comma and

Tou
statement.
(text or
numbers) from the
2. Print is a name of the memory location.
variable within a
of the gram. program 3. Variables are non-executable statements.

4. To accept a value from the user, input statement is used.


message or an
output on the
5. % sign is used with string variables.

B. State the differences between:


1otes (* *). 1. STRING and NUMBER variables
ich may change during 2. INPUT and LET statements
3. PRINT with semicolon () and PRINT with comma ()
4. REM and PRINT statements
C. Write the command for the
its, letters or
following statements.
special 1.
To display "Hello QB64" message on the screen. QRG
2. To leave blank line. Print
nts. a

a blank line. 3. To
Pd
assign a value 10 to
number variable N2.
a
| leave a
space of one 4. To
L Le
assign a string value "ABC" to a
string variable NAME2.
ne space in between. 5. To give comments THIS IS A
SAMPLE PROGRAM.
e the readability of a 6. To
accept class teacher's name in Le AB
the variable
D. Answer the following
questions.
CLTEACHER. Kem sasip
1. What is a PRINT statement?
Give two
tw examples.
2. What is a variable?
Explain two types of
3. What is the use of REM variables.
4. What is the importa
statement? Give an
rtance of the
INPUT example.
5. What is the use of LET
statement? Give statement? Give an
a
small code to
example.
supp
upport yQur
LAB WORK
program
for the following:
Write a
welcome message as
the variables and display a
of two friends in
Accept the
name
end nne, f/3
shown here.
<name2>
end n ard
l> and" anaa
Hi < n a m e Cde
Welcome to my party

PROJECT WORK
of five questions
enter the answer

to
by the
user.
will ask the
user
answers given
program
where you using the them at
Design a quiz friendly
messages
and use
the user
questions
Display of
different
entered by you.
five
answers

variable to input
five a quiz.
Hint:
create
it look ike
to make
places
appropriate

WHOAMI? Hungary.
I
Budapest,
1926 in
on 31 May 1940.
born States in
I was
United
along
with
to the language learn
migrated new to
completely beginners
a for of
enough kinds
developed
I Kurtz,
simple
handle
different

Thomas
E. to
enough
flexible

yet
I n s t r u c t i o n

quickly,
Symbolic
a p p l i c a t i o n s . All-purpose

Beginner's BASIC.

was
the known
as
**********
This commonly *******************
more
***
Code, *****
******

I am...ooooopgo

You might also like