A Tutorial on BASIC Character Set, Variables and Commands

  • Post comments:0 Comments
  • Post category:Blog

In this lesson, I introduce the concept of variables, BASIC character set and how to use some BASIC commands in simple programs.

BASIC was arguably the most popular programming language for many years. It is still a good choice for learning the fundamentals of programming given that it is easy to learn.

Transcript of the video

The BASIC character set includes letters, numbers, punctuation marks and special symbols
used in writing BASIC programs.

a. Numbers:
0—9

b. Letters:
a—z, A—Z

c. Special
characters

i. Mathematical
operators: +, -, /, *, ^ (exponentiation)

ii.
Relational operators: >, >= (greater than or equal to), <, <=,
<> (Not equal)

iv. $ is
added to the end of a variable to denote string. A string is a collection of
characters enclosed in quotation marks. E.g. LET name$ = “James”

v. % is
added to the end of a variable to denote integer. An integer is a whole number.

Variable

A variable
is a named memory space for holding data in a computer’s memory. The name of a
variable cannot start with a number.

Floating point variables hold numbers with decimal points (e.g. -2.435, 7.6712).

USING LET,
REM AND PRINT COMMANDS

Program One

REM This is
a comment

LET greet$ =
“Hello Joy”

PRINT greet$

END

OUTPUT:
Hello Joy

Explanation

REM means
“remark”. It is used for including comments in your program or for
documentation.

LET is used
for declaring a variable and assigning a value to it. Its use is optional.

PRINT is
used for executing a statement or expression and displaying the result on a
screen.

Program Two

10 REM: A
program for calculating the area of a triangle

20 base1 =
12

30 height1
=18

40 area = ½
* base1* height1

50 PRINT
“The area of the triangle is: “; area

60 END

COMMENTS

10, 20, 30…
are called line numbers. Using line numbers is optional in newer versions of
BASIC. You can use comma in place of semi-colon on line 50.

C. O. Daniel

C. O. Daniel holds degrees in Computer Science and certifications from CompTIA and Microsoft. His areas of interest include computer networking, cybersecurity and programming.

Leave a Reply