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

If- else statement - cobol programming, IF ... ELSE STATEMENT: We are ...

IF ... ELSE STATEMENT: We are familiar with an easy form of the IF statement. The common form of the IF statement is as shown below: Each of the statement-1 and statem

Edit characters for numeric data, Edit Characters for Numeric Data: Th...

Edit Characters for Numeric Data: The characters below can be used in the PICTURE clause to indicate the editing.   Z    *  $  -    +    CR    DB    .    ,    B    O    /

Input-output section - cobol programming, INPUT-OUTPUT SECTION: This s...

INPUT-OUTPUT SECTION: This section holds information regarding the files to be used in the program. There are 2 paragraphs in this section- FILE-CONTROL & I-O-CONTROL. The

#title.cobol help , we have input file ,record layout is EMP ID (6 char) , ...

we have input file ,record layout is EMP ID (6 char) , EMP NAME (20 char), Designation (3 char),Salary (5 digit) Base Branch (10char) Grade (3 Alphanumeric). This is the input file

Occurs, what does it used

what does it used

Label records or disk directory - file characteristics, Label Records / Dis...

Label Records / Disk Directory: The most important information stored in the header label is what is termed as the file title. In the situation of magnetic-disk files the labe

Example of nested if statement, Example of Nested if statement: Illus...

Example of Nested if statement: Illustration: Consider the following sentence The nested IF sentence holds two IFs and one ELSE. The IF-ELSE couple has been marke

Valid and invalid word - cobol words, Valid and Invalid Word - Cobol words:...

Valid and Invalid Word - Cobol words: Valid Word             Invalid Word & Reason emp-sal                  -pay   ( it starts with a hyphen)  TOTAL MARK (blank space em

Block size - file characteristics , Block Size: The normal practice is...

Block Size: The normal practice is to group a number of consecutive records to form that is termed as a block or a physical record. The number of records in a block is frequen

Introduction to cobol, Introduction to COBOL: In the year 1959, a new ...

Introduction to COBOL: In the year 1959, a new language named the COBOL ( CO mmon B usiness O riented L anguage) was introduced remembering the business purpose application

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