How to resolve the algorithm Pointers and references step by step in the ALGOL 68 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Pointers and references step by step in the ALGOL 68 programming language
Table of Contents
Problem Statement
In this task, the goal is to demonstrate common operations on pointers and references. These examples show pointer operations on the stack, which can be dangerous and is rarely done. Pointers and references are commonly used along with Memory allocation on the heap.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Pointers and references step by step in the ALGOL 68 programming language
Source code in the algol programming language
INT var := 3;
REF INT pointer := var;
INT v = pointer; # sets v to the value of var (i.e. 3) #
REF INT(pointer) := 42; # sets var to 42 #
INT othervar;
pointer := othervar;
pointer := NIL; # 0 cannot be cast to NIL #
[9]INT array;
pointer := array[LWB array];
REF INT alias = var;
INT v2 = alias; # sets v2 to the value of var, that is, 3 #
alias := 42; # sets var to 42 #
printf(($"alias "b("IS","ISNT")" var!"l$, alias IS var));
[9]INT array2;
REF INT ref3 = array2[LWB array2];
[9,9]INT sudoku;
REF [,]INT middle;
middle := sudoku[4:6,4:6];
[30]CHAR hay stack := "straw straw needle straw straw";
REF[]CHAR needle = hay stack[13:18];
needle[2:3] := "oo";
print((hay stack))
You may also check:How to resolve the algorithm Loops/For with a specified step step by step in the Spin programming language
You may also check:How to resolve the algorithm Josephus problem step by step in the Tcl programming language
You may also check:How to resolve the algorithm Wieferich primes step by step in the Quackery programming language
You may also check:How to resolve the algorithm Fermat pseudoprimes step by step in the Quackery programming language
You may also check:How to resolve the algorithm Pan base non-primes step by step in the Pascal programming language