Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to describe the Functionality of the table by using File

Posted By: Guilherme Silva     Category: Cobol     Views: 2211

Write a program to describe the Functionality of the table by using File.

Code for Program to describe the Functionality of the table by using File in Cobol

 IDENTIFICATION DIVISION.
        PROGRAM-ID. PROG.

       ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
         FILE-CONTROL
          SELECT FILE1 ASSIGN TO DISK 
          ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.
        FILE SECTION
       FD FILE1 
         LABEL RECORDS ARE STANDARD 
         VALUE OF FILE-ID IS "IN2.TXT".

        01 STD-REC.
         05 ROW1 OCCURS 2 TIMES.
          10 COL1 PIC 99 OCCURS 3 TIMES.


        WORKING-STORAGE SECTION.

         01 REC2.
          05 ROW2 OCCURS 2 TIMES.
           10 COL2  PIC 99 OCCURS 3 TIMES.

         01 ANS1 PIC X VALUE "Y".
         
         01 DASH2 PIC X VALUE ALL "-".

         01 I PIC 9.
         01 J PIC 9.

        PROCEDURE DIVISION.
        
        PARA1.
         
             OPEN OUTPUT FILE1.

             WRITE STD-REC FROM DASH2.
          
             PERFORM PARA2 UNTIL ANS1 ="N".
             CLOSE FILE1.
             STOP RUN.


         PARA2.
             PERFORM VARYING I FROM 1 BY 1 UNTIL I IS GREATER THAN 2
             PERFORM VARYING J FROM 1 BY 1 UNTIL J IS GREATER THAN 3
             DISPLAY "ENTER THE NO(" I ")(" J ")"
             ACCEPT COL2(I,J).


             PERFORM VARYING I FROM 1 BY 1 UNTIL I IS GREATER THAN 2
             PERFORM VARYING J FROM 1 BY 1 UNTIL J IS GREATER THAN 3
          
             MOVE COL2(I,J) TO COL1(I,J)
       
             END-PERFORM
 
             END-PERFORM.

             WRITE STD-REC.
             DISPLAY "CONTINUE (Y/N)".
             ACCEPT ANS1.


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

010203040506
112313141516
  
Share: 



Guilherme  Silva
Guilherme Silva author of Program to describe the Functionality of the table by using File is from Salvador, Brazil.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!