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

Blank insertion and zero insertion, B (Blank Insertion) : The occurren...

B (Blank Insertion) : The occurrence of a B anyplace in the picture will insert a space character in the edited data. There can be more than one B in the picture. Examples:

Rules of renames clause, RULES OF RENAMES CLAUSE:   The rules below s...

RULES OF RENAMES CLAUSE:   The rules below should be observed while using the RENAMES clause: (i) All RENAMES entries should be written only after the last record descript

Direct organization, Direct Organization: Besides the relative or inde...

Direct Organization: Besides the relative or indexed organization, also a direct access file can be designed to have what is termed as direct organization.  In this organizati

Sign condition - cobol programming, SIGN CONDITION:   The sign condit...

SIGN CONDITION:   The sign condition establishes whether or not the algebraic value of an operand is negative, positive or zero. The operand can be either the numeric identif

Subtract verb, SUBTRACT VERB: The SUBTRACT verb is used to subtract on...

SUBTRACT VERB: The SUBTRACT verb is used to subtract one, or the sum of two or more numbers from one or more numbers and to store the result. The form of the SUBTRACT verb

Example of class condition, Example of Class condition: Let the BASIC-...

Example of Class condition: Let the BASIC-PAY be a data name in the card record defined with picture 9(5) V99. By reading the card we can test the value of the BASIC-PAY to ma

Subscript and index, What is the difference between subscript and index

What is the difference between subscript and index

Floating insertion - , Floating Insertion   The currency symbol ($) c...

Floating Insertion   The currency symbol ($) can emerge in multiples on the left-hand side of the picture. In this situation the character will be treated in similar way as t

#verbs, Display control verbs in Cobol

Display control verbs in Cobol

Different data types available in cobol, Data types available in COBOL are ...

Data types available in COBOL are given below Alpha-numeric (X), numeric (9), alphabetic (A)

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