How to resolve the algorithm Loops/Continue step by step in the COBOL programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Loops/Continue step by step in the COBOL programming language

Table of Contents

Problem Statement

Show the following output using one loop.

Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Loops/Continue step by step in the COBOL programming language

Source code in the cobol programming language

       IDENTIFICATION DIVISION.
       PROGRAM-ID. loop-continue.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  i PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING i FROM 1 BY 1 UNTIL 10 < i
               DISPLAY i WITH NO ADVANCING

               IF FUNCTION MOD(i, 5) = 0
                   DISPLAY SPACE
                   EXIT PERFORM CYCLE
               END-IF

               DISPLAY ", " WITH NO ADVANCING
           END-PERFORM

           GOBACK
           .


  

You may also check:How to resolve the algorithm Bulls and cows step by step in the Frink programming language
You may also check:How to resolve the algorithm Luhn test of credit card numbers step by step in the Factor programming language
You may also check:How to resolve the algorithm Loops/Foreach step by step in the Vala programming language
You may also check:How to resolve the algorithm Modular exponentiation step by step in the Phix programming language
You may also check:How to resolve the algorithm Color of a screen pixel step by step in the Scala programming language