Monday, November 26

Modes of operation

BASIC may be used in either of two modes :
1. Direct Mode or
2. Indirect Mode
1. Direct mode : In this mode, BASIC statements and commands are executed as they are entered. You can see the results of arithmetic and logical operations displayed immediately, but the instructions themselves are lost after execution.
This mode is useful  for using BASIC as a calculator for quick computations that don't require a complete program. In this mode BASIC statements are written without line numbers.
Example 1 : Suppose, there are two numbers A and B.
A = 25
B = 10
CS 1.1 Display on the screen fro Direct Mode
Ok
PRINT 25+10
35
Ok
PRINT 25-10
15
Ok
PRINT 25*10
250
Ok
PRINT 25/10
2.5
Ok

2. Indirect Mode : The Indirect mode is used to enter programs. As you know, a program is a sequence of instructions, each instruction or statement is written after a line number. The program stored in memory is executed by entering the RUN command.
Example 2
Suppose, there are two numbers A and B (Similar to the previous example of direct mode)
A = 25
B = 10
CS 1.3 Display on the screen fro Indirect Mode  
Ok
LIST
10       INPUT " THE VALUE OF FIRST NUMBER IS :" ; A
20       INPUT " THE VALUE OF SECOND NUMBER IS :"; B
30       S=A+B
40       D=A-B
50       P=A*B
60       Q=A/B
70       PRINT " THE SUM OF A AND B IS : "; S
80       PRINT " THE DIFFERENCE OF A AND B IS :" ; D
90       PRINT " THE PRODUCT OF AND B IS :"; P
100    PRINT " THE QUOTIENT OF A DIVIDED BY B IS :"; Q
Ok
RUN
THE VALUE OF FIRST NUMBER IS : ? 25
THE VALUE OF SECOND NUMBER IS : ? 10
THE SUM OF A AND B IS : 35
THE DIFFERENCE OF A AND B IS : 15
THE PRODUCT OF A AND B IS : 250
THE QUOTIENT OF A DIVIDED BY B IS : 2.5
Ok
If you compare Example 1 and Example 2, you will come to know that the result of calculation is obtained immediately after writing the formula and pressing Enter key as in the case of direct mode of operation, but, in indrect mode, the program is to be run to get the same result.    

                    
          

No comments:

Post a Comment