COBOL format you need for arithmetic logic

In COBOL there are many scenarios you need to ADD or Subtract. In all the scenarios many programmers confuse what format they need to choose.

Here are my ideas…

Let me take an example of Subtract and explain it. Here there are two formats. You can choose anyone. That is depending on your requirement.

COBOL format for ADD or Subtract
Stocksnap.io

In the Format-1…

Subtract a1 b1 c1 from T1 T2 T3

In the above code, you are subtracting three values from the source values. This happens the way you have given the order, and it subtracts in the order you mentioned.

Example: a1 b1 c1 is subtracted from T1….and so on

In the Format-2

Subtract a1 b1 c1 from T1

Subtract a1 b1 c1 from T2

Subtract a1 b1 c1 from T3

The point is , which format you need to choose. In the Format-1 you can cannot retain the values of T2,T3. Since all the values (T1,T2, T3) will be subtracted in sequence at a time.

Where as in the Format-2 you can retain the values of T2 and T3. Since, after T1 is subtracted still you have time to check values of T2 and T3.

You need to choose format depends on your requirement.

General rule – After Subtract or ADD  statement you need to give one space. Comma is an optional, but space you need to give.

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.