You are on page 1of 8

12.1.

2 RECOGNIZE DIFFERENT TYPES OF INSTRUCTIONS USED IN BASIC


Instruction
• Collection of instructions/statements is called a program .
• In GW-BASIC , there are three types instruction as given below
(a) Command
(b) Statement
(c) Functions
1. STATEMENTS
• A Statements is a group of BASIC keywords(Reserved words).
• A Statement is a part of program.
• Statements are a part of a computer program and run in compiler’s mode or
indirect mode or programming mode.
• Statement always preceded by line number.
• When the program RUN, statements are executed.
• A Program statement in BASIC has two parts in general, a line number and one or
more BASIC instructions. Line number tells the position of a statement in a
program and must be a positive integer from 0 to 65529
• Basic Statements are either executable statements or non-executable as shown
in below diagram
Executable Statements STATEMNTS Non-Executable
are instructions that Statements Do not
tell BASIC interpreter cause any
what to do program action but they
provide necessary
Executable For Example Non- Executable For Example information to program
PRINT , INPUT , GOTO, LET REM ,DATA and FIELD

Imperative For Example Conditional For Example IF–


PRINT , INPUT , GOTO , CLS THEN-ELSE , WHILE-WEND,FOR-
NEXT,ON-GOTO,ON-GOSUB
Imperative Statements
are those statements Conditional Statements
which do not depend are those statements
on other factors . which perform a
defined condition.
2. COMMANDS
• Commands are generally executable instructions .
• They are run in direct mode .
• Commands usually perform some type of program maintenance such as editing ,
clearing , runing and saving programs.
• Commands generally operate on a program.
• For example
LIST (F1) , RUN (F2) , LOAD (F3) , SAVE (F4) , CONT (F5) , LPT1 (F6) , TRON (F7)
,TROFF(F8) , KEY (F9) , SCREEN(F10) , AUTO (Alt + A) , CLEAR , DELETE , NEW
FILES , KILL, RENUM , EDIT , BREAK(Ctrl + C) , SYSTEM
3. FUNCTIONS
• A function is a routine that takes a value (string or number) as an input, and
produce a single value as output.
• A function is a predetermined operation that is performed on an operand
• Most programming language including BASIC contain built-in functions that
perform arithmetic and string operations .
• These built-in functions are also called library functions
• These functions make the programming much simpler and also reduce the
labour and save time in programming .
• There are two types of functions : System-defined functions and user-defined
functions.
For Example
ABS Function , LOG function , SQR function , SIN function
STATEMENTS COMMANDS FUNCTIONS
• REM • LIST • ABS
• END • RUN • LOG
• INPUT • LOAD • SQR
• READ-DATA • EDIT
• PRINT • CLEAR
• LET • DELETE
• NEW
• RENUM
• AUTO
BASIC COMMANDS

You might also like