Operators perform mathematical or logical operations
on values. In basic the operators are divided into four categories.
- Arithmetic
- Relational
- Logical
- Functional
Numeric expressions contain operators that perform
arithmetic operations such as addition, subtraction; multiplication etc. theses
are called arithmetic operators. The following special symbols are used in
Basic language.
Arithmetic Operators Table |
RELATIONAL OPERATORS:
Relational operators are used to relate or compare
two quantities. The result of comparison may be either Yes or No or may be True
or False.
OPERATOR
|
RELATION
|
EXAMPLE
|
=
|
Equality
|
If A= 15 then stop.
|
< >
|
Inequality
|
If D$< > Sunday then display welcome.
|
<
|
Less than
|
If M<50 then print fail.
|
>
|
Greater than
|
If M>50 then print congratulation
|
< =
|
Less than or equal to
|
If K<=10 then go to step 70.
|
> =
|
Greater than or equal to
|
If G>=17 then
X=x*2 otherwise, X= x*1.5
|
INPUT STATEMENT:
The input put assigning values to variable this
statement allows to enter value of a variable while the program is running. The
format of the input Statement is:
LINE# Input (Variable name)
Read----------Data
Statements
The LET Statement assigns values from within a
program and the input statement allows you to supply the values while the
program is running. There is a third method using read and Data statements.
This is useful when the data contains large numbers of values. A Data statement
contains of the variable which are assigned to the respective variable names in
Read statement. The format of Read and Data statements are:
Line# Read (1st
Variable name),(2nd Variable name),…………..
Line #Data (Value of 1st
Variable), (Value of 2nd Variable),……….
PRINT STATEMENT:
Print statement when executed, displays the
processing results of the computer. Print Statement is similar to print command
used in compiler mode. Print is followed by a line number such as:-
LINE#{……………………………..}
LET STATEMENT:
LET is an assignment statement that stores a value
in a location assigned to a given variable. The general format of the LET
statement is as follows:-
LINE# LET variable =
expression
LOGICAL OPERATORS:
Logical Operators such as AND, OR, NOT, NAND, NOR,
and XOR perform in the same way as in Booker algebra. The result of these
logical operations would be either True or False.
For example an allowance of Rs. 1,000 is announced
for employees under grade 12 of firms whose stuff members are more than 4. It
may be expressed as:-
If G < 12 and MEM>4
then All= 1000
Excellent grade is awarded to students getting 80% or
more marks or total marks 360 above. This can be expressed.
IF M> = 80 OR TOT>=360
Then GR$=Excellent
FUNCTIONAL OPERATORS:
Basic is very rich in having predetermined functions
that perform arithmetic and string operations. These are built in functions such
as ABS, INT, FIX, RND, SQR, LOG, SIN and COS .
0 Comments:
Post a Comment