Program using occurs clause, COBOL Programming

Assignment Help:

PROGRAM USING OCCURS CLAUSE:

We have to write a simple program to demonstrate Occurs Clause. Get the employee details for 3 persons and compute the total salary.

identification division.

  program- id. emp-occurs.

  environment division.

  data division.

  working-storage section.

  01  emp-rec.

    02 emp-det occurs 3 times.

      05 emp-name  pic x(20).

      05 emp-sal   pic 9(5)v9(2).

  01 head-1   pic x(80) value all "- ".

  01 head-2.

    02  f  pic x(15) Value spaces.

    02  f  pic x(20) value "NAME".

    02  f  pic x(15) Value spaces.

    02  f  pic x(10) value "SALARY".

    02  f pic x(20) value spaces.

01 head-3.

  02  f pic x(15) value spaces.

  02  e-name pic x(20).

  02  f  pic x(15) Value spaces.

  02  e-sal   pic z(5).z(2).

  02  f  pic x(22) Value spaces.

01   i  pic 9 value 1.

01   tot-sal pic 9(6)v9(2) value 0.

01   e-tot-sal pic z(6).z(2).

procedure division.

para-1.

  display(1 1) erase.

  display(3 5) "Enter Data for 3 Employees...".

  perform get-para 3 times.

  display head-1.

  display head-2.

  display head-1.

  move 1 to i.

  perform disp-para until i > 3.

  display head-1.

  move tot-sal to e-tot-sal.

  display "Total Salary = " e-tot-sal.

  display " ".

  stop run.

get-para.

  display(1 1) erase.

  display(5 5) "Name :  ".

  accept emp-name(i).

  display(10 5) "Salary : ".

  accept emp-sal(i).

  add 1 to i.

disp-para.

  move  emp-name(i) to e-name.

  move  emp-sal(i)  to e-sal.

  compute tot-sal = tot-sal + emp-sal(i).

  display head-3.

  add 1 to i.


Related Discussions:- Program using occurs clause

Delete statement - indexed files, DELETE STATEMENT : The file should be...

DELETE STATEMENT : The file should be opened in the I-O mode. If the access is SEQUENTIAL, the INVALID KEY phrase must be specified. Rather than, the last input-output state

Move verb - cobol programming, Introduction to MOVE Verb: The aim of th...

Introduction to MOVE Verb: The aim of this section is to introduce the learner how to move data from one place to the other place in the memory. This is completed with the help

Transaction file - file updation, Transaction file : A transaction file...

Transaction file : A transaction file is a file which contains new records those changes to old records which are used to update the master file. The problem of file updatio

Program for compute verb, PROGRAM FOR COMPUTE VERB: We have to write a...

PROGRAM FOR COMPUTE VERB: We have to write an easy program to elaborate the COMPUTE verb.  Identification division. Program- id. compverb. Environment division. Da

Record description for the variable-length records, Record Description for ...

Record Description for the Variable-length Records: When the variable- length records consists of records of various lengths, each record type is to be explained at level 01 f

Write statement, WRITE STATEMENT: The WRITE Statement verb releases a r...

WRITE STATEMENT: The WRITE Statement verb releases a record in an output file. The syntax for the WRITE statement can be unlike depending on the output device and the medium us

Group item as operand in the relational condition, Group Item as Operand in...

Group Item as Operand in the Relational Condition: Whenever an operand of a relational condition is the group item, the item is then considered to be an alphanumeric field. Th

Numeric literals - cobol program, Numeric -   Literals : The numeri...

Numeric -   Literals : The numeric literal can be created with the help of digits only. It can have a sign (+ or -) and can also have a decimal point. If no sign is specifi

Example of redefines clause, Example of Redefines clause: This illustr...

Example of Redefines clause: This illustration describes a sales record that may either contain the total amount of sale or the quantity (QTY) and UNIT-PRICE. The aim of such

Divide verb, DIVIDE VERB: The aim of the DIVIDE verb is to divide one ...

DIVIDE VERB: The aim of the DIVIDE verb is to divide one number by the other and to store the result.  There are few forms of this verb. One of its forms is as shown below:

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd