How to resolve the algorithm Count in octal step by step in the Simula programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Count in octal step by step in the Simula programming language
Table of Contents
Problem Statement
Produce a sequential count in octal, starting at zero, and using an increment of a one for each consecutive number. Each number should appear on a single line, and the program should count until terminated, or until the maximum value of the numeric type in use is reached.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Count in octal step by step in the Simula programming language
Source code in the simula programming language
BEGIN
PROCEDURE OUTOCT(N); INTEGER N;
BEGIN
PROCEDURE OCT(N); INTEGER N;
BEGIN
IF N > 0 THEN BEGIN
OCT(N//8);
OUTCHAR(CHAR(RANK('0')+MOD(N,8)));
END;
END OCT;
IF N < 0 THEN BEGIN OUTCHAR('-'); OUTOCT(-N); END
ELSE IF N = 0 THEN OUTCHAR('0')
ELSE OCT(N);
END OUTOCT;
INTEGER I;
WHILE I < MAXINT DO BEGIN
OUTINT(I,0);
OUTTEXT(" => ");
OUTOCT(I);
OUTIMAGE;
I := I+1;
END;
END.
You may also check:How to resolve the algorithm Execute Brain step by step in the PHP programming language
You may also check:How to resolve the algorithm Multifactorial step by step in the C++ programming language
You may also check:How to resolve the algorithm Abelian sandpile model/Identity step by step in the REXX programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the Ceylon programming language
You may also check:How to resolve the algorithm File input/output step by step in the Lisaac programming language