How to resolve the algorithm Return multiple values step by step in the ALGOL 68 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Return multiple values step by step in the ALGOL 68 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 ALGOL 68 programming language
Source code in the algol programming language
# example mode for returning multiple values from a procedure #
MODE PAIR = STRUCT( STRING name, INT value );
# procedure returning multiple values via a structure #
PROC get pair = ( INT a )PAIR:
CASE a
IN #1# ( "H", 0 )
, #2# ( "He", 1 )
, #3# ( "Li", 3 )
OUT ( "?", a )
ESAC
;
main: (
# use the result as a whole #
print( ( get pair( 3 ), newline ) );
# access the components separately #
print( ( name OF get pair( 1 ), value OF get pair( 2 ), newline ) )
)
You may also check:How to resolve the algorithm Peaceful chess queen armies step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Evaluate binomial coefficients step by step in the PHP programming language
You may also check:How to resolve the algorithm Comments step by step in the LiveCode programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Whenever programming language
You may also check:How to resolve the algorithm Sokoban step by step in the Kotlin programming language