Tuesday, May 7

BASIC Statements

Program comments - the REM Statement 
The REM statement allows remarks to be inserted in program.
Syntax
LN REM  [comment]
'                 [comment]
Where, 
LN : Line Number
Comment : Remarks written by the programmer
'                : Apostrophe (') may be used in place of REM.
Points to Remember :

  •  REM statements are not executed, but they are listed with all other.
  • Statements in BASIC program.
  • Once REM or ' (apostrophe) is encountered, the program ignores everything until the next line number is encountered.
  • REM Statement may be branched into from GOTO or GOSUB statement.
  • Remarks can be added to the end of a line by an apostrophe (') instead of REM.
Example 1

1. 10 REM This program calculates percentage.
2. 20 REM Program to find area of a triangle
3. 30 REM " My Test Result"
4. 40 REM A = x + y 'Addition of x and y
Use of REM statement and apostrophe (') in the program. Suppose we have two numbers.
x = 20
y = 10
Now, we will write a program to add  these two numbers. The remarks are written using REM statement and apostrophe (')

CS 4.1 Display on the screen for REM statement

Ok
LIST 
10  REM Learning the use of REM statement
20  REM Values of two numbers x and y
30  X = 20
40  Y = 10
50  REM Addition of two numbers x and y
60  A = X+Y
Ok
RUN
Ok


CS 4.2 Display on the screen for REM statement

Ok 
LIST 
10 REM Learning the use of REM and apostrophe (') statement
20 REM Values of two numbers X and Y
30 X =20 'VALUE OF X
40 Y = 10 ' VALUE OF Y
50 REM Addition of two numbers X and Y
60 A=X+Y 'Addition of X and Y
Ok
RUN
Ok          

  

No comments:

Post a Comment