COBOL compute add 코볼 연산 명령

코볼 숫자 계산

COMPUTE  TOT = A1 * 2 + C.
COMPUTE N = (X-Y)**2 + (Z-R)/2.
COMPUTE    TOT  =  A + B + C.

MOVE 0 TO CNT .
ADD 1 TO CNT. 
ADD A B GIVING C.

SUBTRACT   T-TAX  FROM  T-SUDANG.
SUBTRACT A B C FROM T
SUBTRACT CORR I-REC FROM O-REC.
SUBTRACT A FROM B 
 ON SIZE ERROR DISPLAY “*자리수 부족*".
SUBTRACT A B C FROM 100 GIVING YY.


MULTIPLY    A   BY     B.            
MULTIPLY   10.5   BY   KK  ROUNDED.   
MULTIPLY   A   BY   B  
   ON  SIZE  ERROR    DISPLAY "자리수 부족".

DIVIDE TOTAL-TOTAL(I) BY TOT-CNT
                GIVING AVE-TOTAL(I).
DIVIDE    A   INTO   B       
DIVIDE   99  BY  2 GIVING MOK
                    REMAINDER NAM.     . 
DIVIDE   10.5   INTO  KK  ROUNDED. 
DIVIDE   A  INTO  B  
   ON  SIZE ERROR DISPLAY "자리수 부족".




COMPUTE
COMPUTE  identifier  [ ROUNDED ] = 연산식  
[  ON SIZE ERROR  무조건문-1 ]  [ NOT ON SIZE ERROR 무조건문-2 ]
[ END-COMPUTE ]




ADD
ADD   { identifier-1 / literal-1 } [ identifier-2 / literal-2 ] ... TO identifer-n [ ROUNDED]
[ ON SIZE ERROR 무조건문 -1 ] [ NOT ON SIZE ERROR 무조건문-2 ]
[ END-ADD ]
ADD  { identifier-1 / literal-1 } [ identifier-2 / literal-2 ]  ...        GIVING  identifier-n   [ROUNDED]
[ ON SIZE ERROR 무조건문-1 ] [ NOT ON SIZE ERROR 무조건문-2 ]
[ END-ADD ]
ADD  { CORRESPONDING / CORR }    identifier-1  TO  identifier-n   [ ROUNDED] }
[ ON SIZE ERROR 무조건문-1 ] [ NOT ON SIZE ERROR 무조건문-2 ]
[ END-ADD ]


SUBSTRACT
SUBSTRACT   { identifier-1 / literal-1 } [ identifier-2 / literal-2 ] ... FROM identifer-n [ ROUNDED]
[ ON SIZE ERROR 무조건문 -1 ] [ NOT ON SIZE ERROR 무조건문-2 ]
[ END-SUBSTRACT ]
SUBSTRACT  { CORRESPONDING / CORR }    identifier-1  FROM  identifier-n   [ ROUNDED] }
[ ON SIZE ERROR 무조건문-1 ] [ NOT ON SIZE ERROR 무조건문-2 ]
[ END-SUBSTRACT ]


MULTIPLY
MULTIPLY   { identifier-1 / literal-1 } [ identifier-2 / literal-2 ] ... BY identifer-n [ ROUNDED]
[ ON SIZE ERROR 무조건문 -1 ] [ NOT ON SIZE ERROR 무조건문-2 ]
[ END-MULTIPLY ]
MULTIPLY  { identifier-1 / literal-1 } [ identifier-2 / literal-2 ]  ...        GIVING  identifier-n   [ROUNDED]
[ ON SIZE ERROR 무조건문-1 ] [ NOT ON SIZE ERROR 무조건문-2 ]
[ END-MULTIPLY ]
MULTIPLY  { CORRESPONDING / CORR }    identifier-1 BY  identifier-n   [ ROUNDED] }
[ ON SIZE ERROR 무조건문-1 ] [ NOT ON SIZE ERROR 무조건문-2 ]
[ END-MULTIPLY ]


DIVIDE
DIVIDE  { identifier-1  / literal-1 }    INTO      identifier-2       [ ROUNDED]
[ ON SIZE ERROR 무조건문-1 ] [ NOT  ON SIZE ERROR 무조건문-2 ]
[ END-DIVIDE ]
DIVIDE { identifier-1 / literal-1  }         {  INTO /   BY  }      { identifier-2  / literal-2 } 
GIVIING  identifier-3   [ ROUNDED ] [ REMAINDER ]  identifier-4
[ ON SIZE ERROR 무조건문-1 ] [ NOT  ON SIZE ERROR 무조건문-2 ]
[ END-DIVIDE ]






Written by dukgun.com

Post a Comment

أحدث أقدم