Elias Sunny
STATEMENTS
A statement (for the QBASIC) is a set of
instructions written by using keywords or
commands of QBASIC. Every programming
language uses keywords as a statement
with certain syntax. The keywords have
specific meaning in the QBASIC
programming. The statements are the first
stored in the memory and executed only
when the RUN command is given.
1. CLS Statement
The CLS statement clears the screen. If
you write CLS statement in the middle of
the program then you cannot see the
outputs generated before execution of CLS
because it clears the screen.
Syntax: CLS
2. LET Statement
LET is an assignment statement. It is used
to assign the value to a variable. LET is an
optional statement i.e. without using LET
statement one can assign the value to a
variable. The data type must match with
the variable type otherwise type mismatch
error will occur.
Syntax: |LET| variable = value or
expression
Example:
CLS
INPUT ” First Number”; A
INPUT “Second Number”; B
let SUM = A+B
PRINT ” The Sum is”; S
END
3. REM Statement
It is a basic declaration statement that
allows explanatory remarks to be inserted
in a program. The remarks may be useful
in a program to explain about different
kinds of statements and user defined
words. Adding comments in the program
allows us to remind about the program
and also helps other programmers to
understand the logic of the program.
Syntax: REM < Remarks>
Example:
CLS
PRINT “Some text.”
REM This text is ignored.
REM This program clears the output
screen.
REM and then PRINT ” Some text.”
4. PRINT Statement
PRINT statement provides output on the
screen. It prints the values of the
expression on the screen. If the expression
list is blank, no characters are printed. The
expressions in the list may be numeric or
string. In case of number, the negative
number is preceded by a minus sign (-)
but in positive number it is preceded by a
space.
We can use semicolon and comma with a
print statement which results differently
than a normal PRINT statement. If
expression list ends with comma or
semicolon, the next PRINT statement prints
on the same line. Comma provides a TAB
space, but semicolon provides only one
space.
Syntax : PRINT [“Message”]; expression
Example:
CLS
PRINT “Computer is an electronic
machine.”
PRINT
PRINT “IT’s amazing.”
PRINT 1000
PRINT ” The number is: “; 20
END
Output
Computer is electronic machine
IT’s amazing
1000
The number is: 20