How to resolve the algorithm Loop over multiple arrays simultaneously step by step in the Harbour programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Loop over multiple arrays simultaneously step by step in the Harbour programming language
Table of Contents
Problem Statement
Loop over multiple arrays (or lists or tuples or whatever they're called in your language) and display the i th element of each. Use your language's "for each" loop if it has one, otherwise iterate through the collection in order with some other loop.
For this example, loop over the arrays: to produce the output:
If possible, also describe what happens when the arrays are of different lengths.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Loop over multiple arrays simultaneously step by step in the Harbour programming language
Source code in the harbour programming language
PROCEDURE Main()
LOCAL a1 := { "a", "b", "c" }, ;
a2 := { "A", "B", "C", "D" }, ; // the last element "D" of this array will be ignored
a3 := { 1, 2, 3 }
LOCAL e1, e2, e3
FOR EACH e1, e2, e3 IN a1, a2, a3
Qout( e1 + e2 + hb_ntos( e3 ) )
NEXT
RETURN
You may also check:How to resolve the algorithm 15 puzzle game step by step in the Scilab programming language
You may also check:How to resolve the algorithm Pi step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Polymorphism step by step in the Smalltalk programming language
You may also check:How to resolve the algorithm Color of a screen pixel step by step in the QBasic programming language
You may also check:How to resolve the algorithm Middle three digits step by step in the Picat programming language