How to resolve the algorithm Find limit of recursion step by step in the COBOL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Find limit of recursion step by step in the COBOL programming language
Table of Contents
Problem Statement
Find the limit of recursion.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Find limit of recursion step by step in the COBOL programming language
Source code in the cobol programming language
identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
*> room for a better-than-abrupt death here.
exit program.
IDENTIFICATION DIVISION.
PROGRAM-ID. recurse RECURSIVE.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Starter PIC S9(8) VALUE 1.
PROCEDURE DIVISION.
Program-Recurse.
CALL "recurse-sub" USING Starter
STOP RUN.
IDENTIFICATION DIVISION.
PROGRAM-ID. recurse-sub.
DATA DIVISION.
WORKING-STORAGE SECTION.
LINKAGE SECTION.
01 Countr PIC S9(8).
PROCEDURE DIVISION USING Countr.
Program-Recursive.
DISPLAY Countr
ADD 1 TO Countr
CALL "recurse-sub" USING Countr
EXIT PROGRAM.
END PROGRAM recurse-sub.
END PROGRAM recurse.
You may also check:How to resolve the algorithm Levenshtein distance/Alignment step by step in the Arturo programming language
You may also check:How to resolve the algorithm Nonogram solver step by step in the Wren programming language
You may also check:How to resolve the algorithm Leap year step by step in the SNOBOL4 programming language
You may also check:How to resolve the algorithm Compare length of two strings step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Jump anywhere step by step in the Arturo programming language