Cobol Nested Program Example
Posted : adminOn 1/17/2018COBOL programs can contain COBOL. To nested programs and of the COMMON attribute of a nested program, see the Enterprise COBOL for z. Nested program example. COBOL programming site with a full COBOL course as well as lectures, tutorials, programming exercises, and over 50 example COBOL programs.
Explanation of loops in COBOL Looping in the basic COBOL Program These notes will supplement the PowerPoint presentation on looping. Please be sure to look at it and at the sample programs being discussed. ADDDALP.CBL: When we first started looking at programs, we looked at a program called ADDDA.CBL which added two numbers together and displayed the answer.
That program is shown below. IDENTIFICATION DIVISION. *ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 INPUT-AREA.
05 GET-ACCEPT-ANS PIC X VALUE SPACES. 05 FIRST-NUMBER PIC 999 VALUE 0. 05 SECOND-NUMBER PIC 999 VALUE 0. 05 ADD-ANS PIC 9999 VALUE 0. PROCEDURE DIVISION.
DISPLAY 'ENTER THE FIRST NUMBER (UNDER 1000)'. ACCEPT FIRST-NUMBER. DISPLAY 'ENTER THE SECOND NUMBER (UNDER 1000)'. ACCEPT SECOND-NUMBER. ADD FIRST-NUMBER TO SECOND-NUMBER GIVING ADD-ANS. DISPLAY 'THE ANSWER IS ' ADD-ANS.
DISPLAY 'PRESS ENTER TO END THE PROGRAM'. ACCEPT GET-ACCEPT-ANS. Ashlee Simpson Autobiography Rar more. The revised program we will discuss in this handout is ADDDALP.CBL.
This program does the basic math program that we looked at and changes it so that it will keep adding two numbers together until the user decides to stop. The original program simply added two numbers together and the program ended.
The difference between these two program is the PERFORM.UNTIL statement. The PERFORM.UNTIL statement is this program is located in the MAINLINE and is written as: PERFORM B-100-PROCESS UNTIL GET-ACCEPT-ANS = 'Q'. When the statement is executed, it checks the UNTIL first. If GET-ACCEPT-ANS is not equal to Q then the PERFORM does the named paragraph B-100-PROCESS. When all of the commands in that paragraph have been executed and the paragraph is done, control returns to the PERFORM statement. It again checks the UNTIL to see if GET-ACCEPT-ANS is equal to Q.
If it is not, then it executes the PERFORM of B-100-PROCESS. Quickbooks Pro Windows Torrent. Note that at the bottom of B-100-PROCESS the user is asked to enter Q to end the program or just ENTER to continue. The answer that the user enters is stored in GET-ACCEPT-ANS. This means that the user is controlling the program and deciding when it has run enough times.