How to resolve the algorithm Loops/While step by step in the Cowgol programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Loops/While step by step in the Cowgol programming language

Table of Contents

Problem Statement

Start an integer value at   1024. Loop while it is greater than zero. Print the value (with a newline) and divide it by two each time through the loop.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Loops/While step by step in the Cowgol programming language

Source code in the cowgol programming language

include "cowgol.coh";

var n: uint16 := 1024;
while n > 0 loop
    print_i16(n);
    print_nl();
    n := n/2;
end loop;

  

You may also check:How to resolve the algorithm Guess the number/With feedback step by step in the Julia programming language
You may also check:How to resolve the algorithm Comments step by step in the ECL programming language
You may also check:How to resolve the algorithm Loops/Continue step by step in the VBA programming language
You may also check:How to resolve the algorithm Strong and weak primes step by step in the Nim programming language
You may also check:How to resolve the algorithm Assertions step by step in the Ruby programming language