How to resolve the algorithm Show ASCII table step by step in the Cowgol programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Show ASCII table step by step in the Cowgol programming language
Table of Contents
Problem Statement
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Show ASCII table step by step in the Cowgol programming language
Source code in the cowgol programming language
include "cowgol.coh";
# Print number with preceding space if <100 and trailing colon
sub print_num(n: uint8) is
if n < 100 then print_char(' '); end if;
print_i8(n);
print(": ");
end sub;
# Print character / Spc / Del padded to 5 spaces
sub print_ch(c: uint8) is
if c == ' ' then print("Spc ");
elseif c == 127 then print("Del ");
else
print_char(c);
print(" ");
end if;
end sub;
var c: uint8 := 32;
loop
print_num(c);
print_ch(c);
if c == 127 then
break;
end if;
c := c + 16;
if c > 127 then
print_nl();
c := c - 95;
end if;
end loop;
print_nl();
You may also check:How to resolve the algorithm Loops/For with a specified step step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Bitmap/Bresenham's line algorithm step by step in the Erlang programming language
You may also check:How to resolve the algorithm Generator/Exponential step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm Integer comparison step by step in the Bracmat programming language
You may also check:How to resolve the algorithm Hello world/Web server step by step in the Smalltalk programming language