How to resolve the algorithm Arrays step by step in the PL/I programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Arrays step by step in the PL/I programming language

Table of Contents

Problem Statement

This task is about arrays. For hashes or associative arrays, please see Creating an Associative Array. For a definition and in-depth discussion of what an array is, see Array.

Show basic array syntax in your language. Basically, create an array, assign a value to it, and retrieve an element   (if available, show both fixed-length arrays and dynamic arrays, pushing a value into it). Please discuss at Village Pump:   Arrays.
Please merge code in from these obsolete tasks:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Arrays step by step in the PL/I programming language

Source code in the pl/i programming language

/* Example of an array having fixed dimensions */
declare A(10) float initial (1, 9, 4, 6, 7, 2, 5, 8, 3, 10);

A(6) = -45;

/* Example of an array having dynamic bounds. */
get list (N);

begin;
   declare B(N) float initial (9, 4, 7, 3, 8, 11, 0, 5, 15, 6);
   B(3) = -11;
   put (B(2));
end;

/* Example of a dynamic array. */
   declare C(N) float controlled;
   get list (N);
   allocate C;
   C = 0;
   c(7) = 12;
   put (C(9));

  

You may also check:How to resolve the algorithm Zig-zag matrix step by step in the Agena programming language
You may also check:How to resolve the algorithm Hostname step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm OpenGL step by step in the BaCon programming language
You may also check:How to resolve the algorithm Summarize and say sequence step by step in the J programming language
You may also check:How to resolve the algorithm Calendar step by step in the Huginn programming language