How to resolve the algorithm Loops/N plus one half step by step in the M2000 Interpreter programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Loops/N plus one half step by step in the M2000 Interpreter programming language
Table of Contents
Problem Statement
Quite often one needs loops which, in the last iteration, execute only part of the loop body. Demonstrate the best way to do this. Write a loop which writes the comma-separated list using separate output statements for the number and the comma from within the body of the loop.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Loops/N plus one half step by step in the M2000 Interpreter programming language
Source code in the m2000 programming language
Module Checkit {
\\ old type loop
For i=1 to 10
Print i;
If i=10 Then Exit For
Print ", ";
Next i
Print
\\ fast type loop. Continue exit block, without breaking loop.
For i=1 to 10 {
Print i;
If i=10 Then Continue
Print ", ";
}
Print
Print
i=0
{
loop \\ this mark block for loop, each time need to mark
i++
Print i;
If i=10 Then Exit ' so now we use exit to break loop
Print ", ";
}
Print
}
Checkit
You may also check:How to resolve the algorithm Determine sentence type step by step in the Raku programming language
You may also check:How to resolve the algorithm Read a file character by character/UTF8 step by step in the Python programming language
You may also check:How to resolve the algorithm Phrase reversals step by step in the Phixmonti programming language
You may also check:How to resolve the algorithm Environment variables step by step in the Forth programming language
You may also check:How to resolve the algorithm Averages/Median step by step in the Smalltalk programming language