Arithmetic verbs are used to perform computations. Some arithmetic verbs in their most elementary forms are discussed below.
ADD:
This verb can be used to find the sum of two or more numbers and to store the sum. The ADD verb takes any one the following two forms.
Examples:
(a) ADD A TO B
The value of A will be added to the value of B and the result will be stored in B.
(b) ADD A, B GIVING C.
The values of A and B will be added and the sum will be stored in C.
SUBTRACT:
This verb is used to subtract one or the sum of two or more numbers from one or more numbers and to store the result.
The form of the SUBTRACT verb is as follows.
Examples:
(a) SUBTRACT A FROM B.
This statement means that the value of A will be subtracted from the value of B and the subtracted result will be stored in B. The decimal point
(b) SUBTRACT A, B FROM C GIVING D
This indicates that the summation of the value of A and B will be subtracted from the value of C and the final result will be stored in D.
MULTIPLY:
This statement causes one or more multiplicands to be multiplied by a multiplier and to store the products. The form of the MULTIPLY verb is as follows:
Examples:
(a) MULTIPLY A BY B.
The value of A and B will be multiplied and the product will be stored in B.
(b) MULTIPLY A BY B GIVING C.
The value of A and B will be multiplied and the product will be stored in C.
DIVIDE:
The purpose of this verb is to divide one number by another and to store the result. There are several forms of this verb. One of its forms is as follows:
Examples:
DIVIDE 5 INTO A GIVING B.
If the value of A is 20 then after the execution of this statement the value of B will be 4. Here A will retain its old value.
The second form of this verb is as follows:
In this case identifier-1 or numeric- literal – will be divided by identifier-2 or numeric-literal-2, whatever may be the case. The result is stored in identifier-3, identifier-4, etc.
Example:
DIVIDE A BY 3 GIVING C
If the value of A is 21 then after the execution of this statement C will contain 7.
There is another form of DIVIDE verb where there is a provision to store the remainder. Its form is
Examples:
DIVIDE A INTO B GIVING C REMAINDER D
If the identifier A, B, C and D are all two-digited numbers and if they contain 05, 37,18 and 20 respectively before the execution of the statement, then after the execution of the statement, they will contain 05, 37, 07 and 02 respectively.
SEQUENCE CONTROL VERBS
Usually, the statements are executed sequentially one after another. This sequence can be altered with the help of a sequence control verb.
It is used to unconditionally transfer the control to elsewhere in the program. Its form is as follows:
GO TO procedure-name
As a result of the execution of this statement, the control is transferred to the first statement of the paragraph or section mentioned in the procedure name.
Example:
GO TO PARA-1
STOP:
This verb causes the termination of the execution of the object program. Its form is
STOP RUN
Friday, 12 December 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment