How to resolve the algorithm Multiplication tables step by step in the Action! programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Multiplication tables step by step in the Action! programming language

Table of Contents

Problem Statement

Produce a formatted   12×12   multiplication table of the kind memorized by rote when in primary (or elementary) school.

Only print the top half triangle of products.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Multiplication tables step by step in the Action! programming language

Source code in the action! programming language

PROC PrintRight(BYTE num,size)
  BYTE i

  IF num<10 THEN
    size==-1
  ELSEIF num<100 THEN
    size==-2
  ELSE
    size==-3
  FI
  FOR i=1 TO size
  DO
    Put(' )
  OD
  PrintB(num)
RETURN

PROC Main()
  BYTE ARRAY colw=[1 1 1 2 2 2 2 2 2 3 3 3]
  BYTE i,j,x,w

  ;clear screen
  Put(125)

  ;draw frame
  Position(1,3)
  FOR i=1 TO 38
  DO Put($12) OD

  FOR j=2 TO 15
  DO
    Position(36,j)
    Put($7C)
  OD

  Position(36,3)
  Put($13)

  ;draw numbers
  FOR j=1 TO 12
  DO
    x=1
    FOR i=1 TO 12
    DO
      w=colw(i-1)
      IF i>=j THEN
        IF j=1 THEN
          Position(x,j+1)
          PrintRight(i*j,w)
        FI
        IF i=12 THEN
          Position(37,j+3)
          PrintRight(j,2)
        FI
        Position(x,j+3)
        PrintRight(i*j,w)
      FI
      x==+w+1
    OD
  OD
RETURN

  

You may also check:How to resolve the algorithm Compiler/lexical analyzer step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Fraction reduction step by step in the C programming language
You may also check:How to resolve the algorithm Delete a file step by step in the Aime programming language
You may also check:How to resolve the algorithm Primorial numbers step by step in the Scala programming language
You may also check:How to resolve the algorithm Terminal control/Inverse video step by step in the Pascal programming language