VOOZH about

URL: https://www.geeksforgeeks.org/cobol/cobol-include-statement/

⇱ COBOL - Include Statement - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

COBOL - Include Statement

Last Updated : 24 Mar, 2022

The INCLUDE statement refers to the file or the directory mentioned after it and inserts the command present inside that member in the pre-compilation state. Basically, it is used to insert a code block onto a source program.

Syntax:

INCLUDE member-name

Where,

  • The member-name refers to the name of the file that has the source code.

Advantages of using Include:

Following are the advantages of using the INCLUDE statement:

  • Increase the readability of the code and reduce the length of the code.
  • Suppose the same code is used repeatedly inside an application instead of writing the same part of code repeatedly we can use Include which will insert that same code inside a program.
  • Reduce maintenance cost, time, and efforts when the changes are done only once inside the modules which are included in many programs.

Let's take an example of the INCLUDE statement in Cobol.

Example:

Explanation:

The program DEMO2 is using a member ODDEVE with the help of Include syntax in COBOL, when the program executes instead of line INCLUDE ODDEVE  the actual code present inside the member ODDEVE(shown below) is inserted which is logically written to check whether the number is odd or even.

Output:

👁 Image
 
Comment