Search:

# Cobol Articles

Submit Article
 RSS Feeds

# Program to generate arithmetic operation by using evaluate clause

Posted By: Faith Hughes     Category: Cobol     Views: 3848

## 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 add1 VALUES "1","add".
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 "1 ) ADD ".
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 "1"  PERFORM add-para
WHEN "2"  PERFORM sub-para
WHEN "3"  PERFORM mul-para
WHEN "4"  PERFORM div-para
WHEN "5"  PERFORM rem-para
END-EVALUATE.

if calculate="1" or "add"
PERFORM add-para.

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

STOP RUN.

add-para.
ADD a b GIVING c.

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
*******

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

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

 Faith Hughes 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!