How to resolve the algorithm Return multiple values step by step in the COBOL programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Return multiple values step by step in the COBOL programming language

Table of Contents

Problem Statement

Show how to return more than one value from a function.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Return multiple values step by step in the COBOL programming language

Source code in the cobol programming language

       identification division.
       program-id. multiple-values.

       environment division.
       configuration section.
       repository.
           function multiples
           function all intrinsic.

       REPLACE ==:linked-items:== BY ==
       01 a usage binary-long.
       01 b pic x(10).
       01 c usage float-short.
       ==
       ==:record-item:== BY ==
       01 master.
          05 ma usage binary-long.
          05 mb pic x(10).
          05 mc usage float-short.
       ==.

       data division.
       working-storage section.
       :linked-items:

       :record-item:
       
       procedure division.
       sample-main.

       move 41 to a
       move "aaaaabbbbb" to b
       move function e to c

       display "Original: " a ", " b ", " c
       call "subprogram" using a b c
       display "Modified: " a ", " b ", " c
       
       move multiples() to master
       display "Multiple: " ma ", " mb ", " mc

       goback.
       end program multiple-values.

      *> subprogram
       identification division.
       program-id. subprogram.

       data division.
       linkage section.
       :linked-items:

       procedure division using a b c.
       add 1 to a
       inspect b converting "a" to "b"
       divide 2 into c
       goback.
       end program subprogram.

      *> multiples function
       identification division.
       function-id. multiples.

       data division.
       linkage section.
       :record-item:

       procedure division returning master.
       move 84 to ma
       move "multiple" to mb
       move function pi to mc
       goback.
       end function multiples.


  

You may also check:How to resolve the algorithm Ternary logic step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Sum digits of an integer step by step in the Dc programming language
You may also check:How to resolve the algorithm Call a foreign-language function step by step in the Mercury programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the BASIC256 programming language
You may also check:How to resolve the algorithm Generate random chess position step by step in the JavaScript programming language