How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the PL/I programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the PL/I programming language

Table of Contents

Problem Statement

The TPK algorithm is an early example of a programming chrestomathy. It was used in Donald Knuth and Luis Trabb Pardo's Stanford tech report The Early Development of Programming Languages. The report traces the early history of work in developing computer languages in the 1940s and 1950s, giving several translations of the algorithm. From the wikipedia entry: The task is to implement the algorithm:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the PL/I programming language

Source code in the pl/i programming language

Trabb: Procedure options (main); /* 11 November 2013 */

   declare (i, n) fixed binary;
   declare s fixed (5,1) controlled;
   declare g fixed (15,5);

   put ('Please type 11 values:');
   do i = 1 to 11;
      allocate s;
      get (s);
      put (s);
   end;
   put skip(2) ('Results:');
   do i = 1 to 11;
      g = f(s); put skip list (s);
      if g > 400 then put ('Too large'); else put (g);
      free s;
   end;

f: procedure (x) returns (fixed(15,5));
   declare x fixed (5,1);
   return (sqrt(abs(x)) + 5*x**3);
end f;

end Trabb;

  

You may also check:How to resolve the algorithm Munching squares step by step in the Julia programming language
You may also check:How to resolve the algorithm Environment variables step by step in the BBC BASIC programming language
You may also check:How to resolve the algorithm Pangram checker step by step in the Phixmonti programming language
You may also check:How to resolve the algorithm XML/Input step by step in the jq programming language
You may also check:How to resolve the algorithm Self-describing numbers step by step in the Scala programming language