Friday, December 17, 2010

COBOL ADD Operator Example

Syntax
ADD A B C GIVING D E
The GIVING Clause may also specify a list of destination/receiving variables. In that case, sum(addition) is copied to the each of the variables mentioned in the GIVING Clause. For example,
Assume that A = 10, B = 15 and C=20.

Now the sum of A B C = 10 + 15 + 20 = 45. The sum 45 is stored in each of the variables mentioned in the list(D, E). Thus,
D = 45 and E = 45, after the above statement is executed.

Example :

Image16[2]
Result :

Image17[1]