Search:

Submit Article

# Program to generate arithmetic operation by using evaluate clause

Posted By: Reuben Brown     Category: Cobol     Views: 3417

## Code for Program to generate arithmetic operation by using evaluate clause in Cobol

```      IDENTIFICATION DIVISION.
PROGRAM-ID. eva.

DATA DIVISION.

WORKING-STORAGE SECTION.

01 calculate PIC X(6).
88 sub VALUES "2","sub".
88 mul VALUES "3","mul".
88 div VALUES "4","div".
88 rem VALUES "5","rem".

77 choice PIC X(6).
77 a PIC 9(4).
77 b PIC 9(4).
77 c PIC 9(6).

PROCEDURE DIVISION.
DISPLAY "2 ) SUB ".
DISPLAY "3 ) MUL ".
DISPLAY "4 ) DIV ".
DISPLAY "5 ) REM ".

DISPLAY "ENTER THE OPERATION TO BE PERFORMED".
ACCEPT choice.
DISPLAY "ENTER TWO OPERANDS".
ACCEPT a.
ACCEPT b.

EVALUATE choice
WHEN "2"  PERFORM sub-para
WHEN "3"  PERFORM mul-para
WHEN "4"  PERFORM div-para
WHEN "5"  PERFORM rem-para
END-EVALUATE.

disp-para.
DISPLAY "THE RESULT IS " c.

STOP RUN.

sub-para.
SUBTRACT a FROM b GIVING c.

mul-para.
MULTIPLY a BY b GIVING c.

div-para.
DIVIDE a INTO b GIVING c.

rem-para.
DIVIDE a INTO b GIVING a REMAINDER c.

*******
OUTPUT
*******

2 ) SUB
3 ) MUL
4 ) DIV
5 ) REM

1
ENTER TWO OPERANDS
25
30
THE RESULT IS 000055
```
Share:

 Reuben Brown author of Program to generate arithmetic operation by using evaluate clause is from London, United Kingdom. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!