Wednesday, December 19

Types of Variables

In BASIC, there are two types of variables
1. Numeric variables
2. String variables

1. Numeric variables

The numeric variables are divided into
1.1 Real Variable
1.2 integer Variable

1.1. Real variable

A real variable (or real (numeric) variable) is represented by a string letter or single letter followed  by a digit.

  • The value supplied to the real variable should be a real constant.
Table C 2. 10 Real variables
Valid                        Invalid Real Variable
Real Variables        Variables      Invalid reason
A0                            1A                 First character must be a letter
B1                            N*                 No special character is allowed
B9


1.2 Integer variable

An integer variable (or integer(numeric)variable) is represented by a single letter or a single letter followed by a single digit terminated by percentage sign (%).
  • The value supplied to an integer variable must be an integer constant. 

2. String variables

A string variable is represented by a single letter or a single letter followed by a digit terminated by a dollar sign ($).
  • The value supplied to a string variable must be a string constant.
Example 8

Table C 2.11 String variables

Valid String                     Invalid String Variable          
Variables                        Variables        Invalid reason
 
     N$                               12$                Must start with a letter
     N1$                             $ N                $ sign should be at the end
     Z 7 $                            NN                must end with $ sign 

     
  

No comments:

Post a Comment