PetraAI commited on
Commit
3da5d57
1 Parent(s): e1cedcb

Upload 136 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +4 -1
  2. Additional algorithm 1.cpp +11 -0
  3. Additional algorithm 1.py +4 -0
  4. Additional algorithm 10.cpp +4 -0
  5. Additional algorithm 10.py +4 -0
  6. Additional algorithm 11.cpp +15 -0
  7. Additional algorithm 11.py +7 -0
  8. Additional algorithm 12.cpp +14 -0
  9. Additional algorithm 12.py +4 -0
  10. Additional algorithm 13.cpp +16 -0
  11. Additional algorithm 13.py +8 -0
  12. Additional algorithm 14.cpp +18 -0
  13. Additional algorithm 14.py +10 -0
  14. Additional algorithm 15.cpp +17 -0
  15. Additional algorithm 15.py +9 -0
  16. Additional algorithm 16.cpp +21 -0
  17. Additional algorithm 16.py +12 -0
  18. Additional algorithm 17.cpp +16 -0
  19. Additional algorithm 17.py +8 -0
  20. Additional algorithm 18.cpp +4 -0
  21. Additional algorithm 18.py +16 -0
  22. Additional algorithm 19.py +9 -0
  23. Additional algorithm 19a.cpp +17 -0
  24. Additional algorithm 19b.cpp +19 -0
  25. Additional algorithm 19c.cpp +22 -0
  26. Additional algorithm 2.cpp +19 -0
  27. Additional algorithm 2.py +8 -0
  28. Additional algorithm 20.cpp +18 -0
  29. Additional algorithm 20.py +11 -0
  30. Additional algorithm 21.cpp +16 -0
  31. Additional algorithm 21.py +8 -0
  32. Additional algorithm 22.py +8 -0
  33. Additional algorithm 22a.cpp +17 -0
  34. Additional algorithm 22b.cpp +18 -0
  35. Additional algorithm 23.py +13 -0
  36. Additional algorithm 23a.cpp +23 -0
  37. Additional algorithm 23b.cpp +24 -0
  38. Additional algorithm 24.cpp +18 -0
  39. Additional algorithm 24.py +10 -0
  40. Additional algorithm 25.cpp +23 -0
  41. Additional algorithm 25.py +12 -0
  42. Additional algorithm 26.cpp +31 -0
  43. Additional algorithm 26.py +16 -0
  44. Additional algorithm 27.cpp +36 -0
  45. Additional algorithm 27.py +23 -0
  46. Additional algorithm 28.cpp +4 -0
  47. Additional algorithm 28.py +4 -0
  48. Additional algorithm 29.cpp +17 -0
  49. Additional algorithm 29.py +9 -0
  50. Additional algorithm 3.cpp +13 -0
.gitattributes CHANGED
@@ -26,7 +26,6 @@
26
  *.safetensors filter=lfs diff=lfs merge=lfs -text
27
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
28
  *.tar.* filter=lfs diff=lfs merge=lfs -text
29
- *.tar filter=lfs diff=lfs merge=lfs -text
30
  *.tflite filter=lfs diff=lfs merge=lfs -text
31
  *.tgz filter=lfs diff=lfs merge=lfs -text
32
  *.wasm filter=lfs diff=lfs merge=lfs -text
@@ -53,3 +52,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
26
  *.safetensors filter=lfs diff=lfs merge=lfs -text
27
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
28
  *.tar.* filter=lfs diff=lfs merge=lfs -text
 
29
  *.tflite filter=lfs diff=lfs merge=lfs -text
30
  *.tgz filter=lfs diff=lfs merge=lfs -text
31
  *.wasm filter=lfs diff=lfs merge=lfs -text
 
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
55
+ AndroidML.docx filter=lfs diff=lfs merge=lfs -text
56
+ docs-readthedocs-io-en-stable.epub filter=lfs diff=lfs merge=lfs -text
57
+ index.duckdb filter=lfs diff=lfs merge=lfs -text
58
+ sumarabic-1.0-index.jsonl filter=lfs diff=lfs merge=lfs -text
Additional algorithm 1.cpp ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 1. It shows the “Hello world” example for all computer languages used in this work. This is intended as a positive first introduction. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ cout<<"Hello World";
10
+ return 0;
11
+ }
Additional algorithm 1.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 1. It shows the “Hello world” example for all computer languages used in this work. This is intended as a positive first introduction. Note that the source code is in context and works with copy/paste.
3
+
4
+ print ('Hello World')
Additional algorithm 10.cpp ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 10. Example of interesting evaluations in PERL showing that concatenations that use the "+" operator instead of the "." operator, lead to the elimination of the string value from the result, with no error in sight. Note that the source code is out of context and is intended for explanation of the method.
3
+
4
+ // this example is only for PERL
Additional algorithm 10.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 10. Example of interesting evaluations in PERL showing that concatenations that use the "+" operator instead of the "." operator, lead to the elimination of the string value from the result, with no error in sight. Note that the source code is out of context and is intended for explanation of the method.
3
+
4
+ # this example is only for PERL
Additional algorithm 11.cpp ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 11. It shows how constants are declared in different computer languages. Moreover, it shows the difference between constant declaration (second column) and variable declaration (third column). Some computer languages use special keywords and data type declarations, while other computer languages do not. Notice how in certain computer languages where there are no special keywords for defining constants, the difference between constant and variable is made by convention; namely a variable written with an uppercase letter means a constant and a variable written with a lowercase letter means a simple variable whose content can be changed at will. Note that the source code is out of context and is intended for explanation of the method.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ const float a = 3.1415926535;
10
+ float b = 3.1415926535897932;
11
+
12
+ cout<<(a+b);
13
+
14
+ return 0;
15
+ }
Additional algorithm 11.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 11. It shows how constants are declared in different computer languages. Moreover, it shows the difference between constant declaration (second column) and variable declaration (third column). Some computer languages use special keywords and data type declarations, while other computer languages do not. Notice how in certain computer languages where there are no special keywords for defining constants, the difference between constant and variable is made by convention; namely a variable written with an uppercase letter means a constant and a variable written with a lowercase letter means a simple variable whose content can be changed at will. Note that the source code is out of context and is intended for explanation of the method.
3
+
4
+ X = 3.14159265358979323846264 # uppercase signifies the role of a constant
5
+ x = 3.14159265358979323846264
6
+
7
+ print (x + X)
Additional algorithm 12.cpp ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 12. It shows two methods of declaring an empty array. For declaration purposes, computer languages use either square brackets or round brackets to indicate that the variable represents a group of "internal subvariables". On the second column is the array square parentheses type of declaration. On the third column is the array constructor type of declaration. Most computer languages that use the array constructor statement are usually object-oriented. But not all of them; for example Python does not have a special keyword of this kind, preferring the array square parentheses notation. Those declarations that explicitly write the data type for the array, can obviously take any data type. Here the example was given on a string data type for computer languages such as Java, C# and VB. Note that the source code is out of context and is intended for explanation of the method.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[0];
10
+ //or
11
+ //string *A = new string[0];
12
+
13
+ return 0;
14
+ }
Additional algorithm 12.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 12. It shows two methods of declaring an empty array. For declaration purposes, computer languages use either square brackets or round brackets to indicate that the variable represents a group of "internal subvariables". On the second column is the array square parentheses type of declaration. On the third column is the array constructor type of declaration. Most computer languages that use the array constructor statement are usually object-oriented. But not all of them; for example Python does not have a special keyword of this kind, preferring the array square parentheses notation. Those declarations that explicitly write the data type for the array, can obviously take any data type. Here the example was given on a string data type for computer languages such as Java, C# and VB. Note that the source code is out of context and is intended for explanation of the method.
3
+
4
+ A = []
Additional algorithm 13.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 13. It shows how to create a multi-valued one-dimensional array variable using literals. In this example an array variable A is used to store only string literals and an array variable B is used to store integer literals. In languages such as Javascript, PHP, PERL, Ruby or Python, array variables can store several types of literals, including objects. In languages such as Java, C# and VB, array variables can store only one type of literal. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[] = {"a", "b", "c"};
10
+ int B[] = {1, 2, 3};
11
+
12
+ cout<<(A[0] + A[1] + A[2]);
13
+ cout<<(B[0] + B[1] + B[2]);
14
+
15
+ return 0;
16
+ }
Additional algorithm 13.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 13. It shows how to create a multi-valued one-dimensional array variable using literals. In this example an array variable A is used to store only string literals and an array variable B is used to store integer literals. In languages such as Javascript, PHP, PERL, Ruby or Python, array variables can store several types of literals, including objects. In languages such as Java, C# and VB, array variables can store only one type of literal. Note that the source code is in context and works with copy/paste.
3
+
4
+ A = ["a", "b", "c"]
5
+ B = [1, 2, 3]
6
+
7
+ print (A[0] + A[1] + A[2])
8
+ print (B[0] + B[1] + B[2])
Additional algorithm 14.cpp ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 14. It shows the statements by which an array variable A is declared and the statements by which literal values are subsequently inserted into the elements of the array variable. It should be noted that some computer languages such as Javascript, PHP, PERL or Ruby allow the declaration of an empty array variable, after which the values can be inserted into newly declared elements. On the other hand, in other computer languages such as C#, Java, VB and Python, the number of elements in the array variable must be declared before the assignment of values. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[3];
10
+
11
+ A[0] = "a";
12
+ A[1] = "b";
13
+ A[2] = "c";
14
+
15
+ cout<<(A[0] + A[1] + A[2]);
16
+
17
+ return 0;
18
+ }
Additional algorithm 14.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 14. It shows the statements by which an array variable A is declared and the statements by which literal values are subsequently inserted into the elements of the array variable. It should be noted that some computer languages such as Javascript, PHP, PERL or Ruby allow the declaration of an empty array variable, after which the values can be inserted into newly declared elements. On the other hand, in other computer languages such as C#, Java, VB and Python, the number of elements in the array variable must be declared before the assignment of values. Note that the source code is in context and works with copy/paste.
3
+
4
+ A = [0]*3
5
+
6
+ A[0] = "a"
7
+ A[1] = "b"
8
+ A[2] = "c"
9
+
10
+ print (A[0] + A[1] + A[2])
Additional algorithm 15.cpp ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 15. It shows how to access the values stored in the elements of an array variable. An array literal is declared, in which three string values (three separate characters, namely "a", "b", "c") are stored. Then, two variables x and y are declared, which take values from the elements of the array variable A. Then, once assigned to the x and y variables, the string values are displayed in the output for visualization. As it can be observed, the result obtained after the execution is "bc". Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[] = {"a", "b", "c"};
10
+
11
+ string x = A[1];
12
+ string y = A[2];
13
+
14
+ cout<<(x + y);
15
+
16
+ return 0;
17
+ }
Additional algorithm 15.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 15. It shows how to access the values stored in the elements of an array variable. An array literal is declared, in which three string values (three separate characters, namely "a", "b", "c") are stored. Then, two variables x and y are declared, which take values from the elements of the array variable A. Then, once assigned to the x and y variables, the string values are displayed in the output for visualization. As it can be observed, the result obtained after the execution is "bc". Note that the source code is in context and works with copy/paste.
3
+
4
+ A = ["a", "b", "c"]
5
+
6
+ x = A[1]
7
+ y = A[2]
8
+
9
+ print (x + y)
Additional algorithm 16.cpp ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 16. It shows how to change values in existing array elements. An array variable A is declared. String literals are assigned to each element of A. The value from the first element of the array variable A, is assigned to a variable x. Then, a literal string value (ie. "d") is assigned to the second element of variable array A, thus erasing the previous value (ie. "a") from this element. Next, the value from the third element of A is assigned to the second element of A, thus deleting the initial value (ie. "b") from the second element. The value stored in variable x is assigned to the third element of array A. At the end, the values from each element are displayed in the output for inspection. Here, the initial sequence "abc" was transformed into the sequence "dcb". Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[] = {"a", "b", "c"};
10
+ string x;
11
+
12
+ x = A[1];
13
+
14
+ A[0] = "d";
15
+ A[1] = A[2];
16
+ A[2] = x;
17
+
18
+ cout<<(A[0] + A[1] + A[2]);
19
+
20
+ return 0;
21
+ }
Additional algorithm 16.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 16. It shows how to change values in existing array elements. An array variable A is declared. String literals are assigned to each element of A. The value from the first element of the array variable A, is assigned to a variable x. Then, a literal string value (ie. "d") is assigned to the second element of variable array A, thus erasing the previous value (ie. "a") from this element. Next, the value from the third element of A is assigned to the second element of A, thus deleting the initial value (ie. "b") from the second element. The value stored in variable x is assigned to the third element of array A. At the end, the values from each element are displayed in the output for inspection. Here, the initial sequence "abc" was transformed into the sequence "dcb". Note that the source code is in context and works with copy/paste.
3
+
4
+ A = ["a", "b", "c"]
5
+
6
+ x = A[1]
7
+
8
+ A[0] = "d"
9
+ A[1] = A[2]
10
+ A[2] = x
11
+
12
+ print (A[0] + A[1] + A[2])
Additional algorithm 17.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 17. It shows how to get the total number of elements of an array. First an array literal A is declared, that contains three elements, each with a string literal (one character). Next, a variable x is declared and a value is assigned to it. The value in question represents the number of elements in array A and is provided either by an in-built function or by a method of the array object, depending on the computer language used. Finally, the content of variable x is displayed in the output for inspection. One thing to note is that in VB, the ubound internal function returns the last index in the array and not the total number of elements as expected from the other examples. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[] = {"a", "b", "c"};
10
+
11
+ int x = sizeof(A) / sizeof(string);
12
+
13
+ cout<<x;
14
+
15
+ return 0;
16
+ }
Additional algorithm 17.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 17. It shows how to get the total number of elements of an array. First an array literal A is declared, that contains three elements, each with a string literal (one character). Next, a variable x is declared and a value is assigned to it. The value in question represents the number of elements in array A and is provided either by an in-built function or by a method of the array object, depending on the computer language used. Finally, the content of variable x is displayed in the output for inspection. One thing to note is that in VB, the ubound internal function returns the last index in the array and not the total number of elements as expected from the other examples. Note that the source code is in context and works with copy/paste.
3
+
4
+ A = ["a", "b", "c"]
5
+
6
+ x = len(A)
7
+
8
+ print(x)
Additional algorithm 18.cpp ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 18. It presents nested arrays in Javascript, Ruby and Python. Three array variables A, B and C are declared here, each with three literal values. To represent the notion of nested, three other array variables are declared, namely D, E and F, each with three elements that hold one of the arrays A, B or C. To provide yet another level in the nest, a last three-element array variable is declared (ie. G), in which each element takes one of the recently mentioned arrays (ie. D, E or F). Note that the source code is in context and works with copy/paste.
3
+
4
+ // this example was given for Javascript, Python and Ruby.
Additional algorithm 18.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 18. It presents nested arrays in Javascript, Ruby and Python. Three array variables A, B and C are declared here, each with three literal values. To represent the notion of nested, three other array variables are declared, namely D, E and F, each with three elements that hold one of the arrays A, B or C. To provide yet another level in the nest, a last three-element array variable is declared (ie. G), in which each element takes one of the recently mentioned arrays (ie. D, E or F). Note that the source code is in context and works with copy/paste.
3
+
4
+ A = ["a", "b", "c"]
5
+ B = ["d", "e", "f"]
6
+ C = ["g", "h", "i"]
7
+
8
+ D = [A, B, C]
9
+ E = [B, C, A]
10
+ F = [C, B, A]
11
+
12
+ G = [D, E, F]
13
+
14
+ print (A[0])
15
+ print (D[0])
16
+ print (G[0])
Additional algorithm 19.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 19. It shows the way in which multidimensional array variables can be declared. An interesting difference can be observed between two groups of computer languages. A group involving Javascript, PHP, PERL, Ruby or Python and another group involving classic computer languages, namely C#, Java, VB. The first group (ie. Javascript, PHP, PERL, Ruby or Python) uses largely the same type of declaration for several dimensions. The Javascript example shows how to declare two-dimensional and three-dimensional array variables, where the pattern can be followed for any higher dimensions (ie. 4D, 5D, 6D, and so on). In PHP, PERL, Ruby or Python, the exemplification is only repeated for two dimensions and it assumes that for more than two dimensions the declarations can be made in the same way as in Javascript. The second group is more different, where Java, C# and VB are radically different in the way statements are made. Obviously, Java and C# have common syntax elements, but they differ a little in the way the declarations for arrays are made. In VB, the number of dimensions and the number of elements in each dimension are initially declared. Only then these elements in their respective dimensions can receive values by assignment. VB is so radically different when compared to other computer languages, that array variables have a lower bound (read through the LBound function) and an upper bound (read through the UBound function), a property that can open paths in prototyping (especially in science). In the VB examples, each Debug.Print statement line corresponds to a row in the output. Note that the source code is in context and works with copy/paste.
3
+
4
+ A = [["a", 88, 146],
5
+ ["b", 34, 124],
6
+ ["c", 96, 564],
7
+ [100, 12, "d"]]
8
+
9
+ print(A[1][2])
Additional algorithm 19a.cpp ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 19. It shows the way in which multidimensional array variables can be declared. An interesting difference can be observed between two groups of computer languages. A group involving Javascript, PHP, PERL, Ruby or Python and another group involving classic computer languages, namely C#, Java, VB. The first group (ie. Javascript, PHP, PERL, Ruby or Python) uses largely the same type of declaration for several dimensions. The Javascript example shows how to declare two-dimensional and three-dimensional array variables, where the pattern can be followed for any higher dimensions (ie. 4D, 5D, 6D, and so on). In PHP, PERL, Ruby or Python, the exemplification is only repeated for two dimensions and it assumes that for more than two dimensions the declarations can be made in the same way as in Javascript. The second group is more different, where Java, C# and VB are radically different in the way statements are made. Obviously, Java and C# have common syntax elements, but they differ a little in the way the declarations for arrays are made. In VB, the number of dimensions and the number of elements in each dimension are initially declared. Only then these elements in their respective dimensions can receive values by assignment. VB is so radically different when compared to other computer languages, that array variables have a lower bound (read through the LBound function) and an upper bound (read through the UBound function), a property that can open paths in prototyping (especially in science). In the VB examples, each Debug.Print statement line corresponds to a row in the output. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ int A[][2] = {{1,2},
10
+ {3,4},
11
+ {5,6},
12
+ {7,8}};
13
+
14
+ cout<<A[0][1];
15
+
16
+ return 0;
17
+ }
Additional algorithm 19b.cpp ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 19. It shows the way in which multidimensional array variables can be declared. An interesting difference can be observed between two groups of computer languages. A group involving Javascript, PHP, PERL, Ruby or Python and another group involving classic computer languages, namely C#, Java, VB. The first group (ie. Javascript, PHP, PERL, Ruby or Python) uses largely the same type of declaration for several dimensions. The Javascript example shows how to declare two-dimensional and three-dimensional array variables, where the pattern can be followed for any higher dimensions (ie. 4D, 5D, 6D, and so on). In PHP, PERL, Ruby or Python, the exemplification is only repeated for two dimensions and it assumes that for more than two dimensions the declarations can be made in the same way as in Javascript. The second group is more different, where Java, C# and VB are radically different in the way statements are made. Obviously, Java and C# have common syntax elements, but they differ a little in the way the declarations for arrays are made. In VB, the number of dimensions and the number of elements in each dimension are initially declared. Only then these elements in their respective dimensions can receive values by assignment. VB is so radically different when compared to other computer languages, that array variables have a lower bound (read through the LBound function) and an upper bound (read through the UBound function), a property that can open paths in prototyping (especially in science). In the VB examples, each Debug.Print statement line corresponds to a row in the output. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ int B[][2][3] = {
10
+ {{1,2,3},
11
+ {4,5,6}},
12
+ {{7,8,9},
13
+ {10,11,12}}
14
+ };
15
+
16
+ cout<<"\n"<<B[0][1][1];
17
+
18
+ return 0;
19
+ }
Additional algorithm 19c.cpp ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 19. It shows the way in which multidimensional array variables can be declared. An interesting difference can be observed between two groups of computer languages. A group involving Javascript, PHP, PERL, Ruby or Python and another group involving classic computer languages, namely C#, Java, VB. The first group (ie. Javascript, PHP, PERL, Ruby or Python) uses largely the same type of declaration for several dimensions. The Javascript example shows how to declare two-dimensional and three-dimensional array variables, where the pattern can be followed for any higher dimensions (ie. 4D, 5D, 6D, and so on). In PHP, PERL, Ruby or Python, the exemplification is only repeated for two dimensions and it assumes that for more than two dimensions the declarations can be made in the same way as in Javascript. The second group is more different, where Java, C# and VB are radically different in the way statements are made. Obviously, Java and C# have common syntax elements, but they differ a little in the way the declarations for arrays are made. In VB, the number of dimensions and the number of elements in each dimension are initially declared. Only then these elements in their respective dimensions can receive values by assignment. VB is so radically different when compared to other computer languages, that array variables have a lower bound (read through the LBound function) and an upper bound (read through the UBound function), a property that can open paths in prototyping (especially in science). In the VB examples, each Debug.Print statement line corresponds to a row in the output. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ int C[2][3];
10
+
11
+ C[0][0] = 5;
12
+ C[0][1] = 6;
13
+ C[0][2] = 5;
14
+
15
+ C[1][0] = 5;
16
+ C[1][1] = 5;
17
+ C[1][2] = 5;
18
+
19
+ cout<<"\n"<<C[0][1];
20
+
21
+ return 0;
22
+ }
Additional algorithm 2.cpp ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 2. Examples of assignments are shown for multiple computer languages. An important observation is that VB refers to Visual Basic 6.0 (VB6) and VBA syntax, namely the last version of Visual Basic. Thus VB6 lacks aggregate assignment as this style is a relatively new addition to computer languages. VB6 can explicitly declare multiple variables for a certain data type (Dim a, b, c As Integer), however, it lacks the posibility for multiple assignment. Note that the source code is out of context and is intended for explanation of the method.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ int a, b, c;
10
+
11
+ a = 1;
12
+
13
+ a += 1;
14
+
15
+ a = b = c = 1;
16
+
17
+ cout<<(a + b + c);
18
+ return 0;
19
+ }
Additional algorithm 2.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 2. Examples of assignments are shown for multiple computer languages. An important observation is that VB refers to Visual Basic 6.0 (VB6) and VBA syntax, namely the last version of Visual Basic. Thus VB6 lacks aggregate assignment as this style is a relatively new addition to computer languages. VB6 can explicitly declare multiple variables for a certain data type (Dim a, b, c As Integer), however, it lacks the posibility for multiple assignment. Note that the source code is out of context and is intended for explanation of the method.
3
+
4
+ a = 1
5
+ a += 1
6
+ a = b = c = 1
7
+
8
+ print (a + b + c)
Additional algorithm 20.cpp ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 20. Demonstrates the implementation of conditional statements. Three variables a, b and c are declared and assigned to different values. A condition triggers a statement to increment the value of variable c, only if the value of variable a is less than the value of variable b, otherwise a decrement is applied to the value of c. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ int a = 1;
10
+ int b = 2;
11
+ int c = 3;
12
+
13
+ if(a < b){c += 1;} else {c -= 1;}
14
+
15
+ cout<<"c="<<c;
16
+
17
+ return 0;
18
+ }
Additional algorithm 20.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 20. Demonstrates the implementation of conditional statements. Three variables a, b and c are declared and assigned to different values. A condition triggers a statement to increment the value of variable c, only if the value of variable a is less than the value of variable b, otherwise a decrement is applied to the value of c. Note that the source code is in context and works with copy/paste.
3
+
4
+ a = 1
5
+ b = 2
6
+ c = 3
7
+
8
+ if a < b: c += 1
9
+ else: c -= 1
10
+
11
+ print ("c=" + str(c))
Additional algorithm 21.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 21. Demonstrates the implementation of conditional statements on array variables. Three elements of an array variable (A) are declared and filled with values. A condition triggers a statment to increment the value of the last element of the array (ie. A[2]), only if the value of the first element (ie. A[0]) is less than the value of the second element (ie. A[1]), otherwise a decrement is applied to the value of the last element of the array. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ int A[] = {1, 2, 3};
10
+
11
+ if(A[0] < A[1]){A[2] += 1;}
12
+
13
+ cout<<"A[2]="<<A[2];
14
+
15
+ return 0;
16
+ }
Additional algorithm 21.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 21. Demonstrates the implementation of conditional statements on array variables. Three elements of an array variable (A) are declared and filled with values. A condition triggers a statment to increment the value of the last element of the array (ie. A[2]), only if the value of the first element (ie. A[0]) is less than the value of the second element (ie. A[1]), otherwise a decrement is applied to the value of the last element of the array. Note that the source code is in context and works with copy/paste.
3
+
4
+ A = [1, 2, 3];
5
+
6
+ if A[0] < A[1]: A[2] += 1
7
+
8
+ print ("A[2]=" + str(A[2]))
Additional algorithm 22.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 22. Here the positive increment while-loop structure is demonstrated. A variable i is declared and set to zero. A while loop structure increments variable i from its initial value to its upper limit (number five). At each iteration, variable i is printed in the output. The result is an enumeration of values from 0 to 4. Note that the source code is in context and works with copy/paste.
3
+
4
+ i = 0
5
+
6
+ while i < 5:
7
+ print('i = ' + str(i))
8
+ i += 1
Additional algorithm 22a.cpp ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 22. Here the positive increment while-loop structure is demonstrated. A variable i is declared and set to zero. A while loop structure increments variable i from its initial value to its upper limit (number five). At each iteration, variable i is printed in the output. The result is an enumeration of values from 0 to 4. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ int i = 0;
10
+
11
+ while (i < 5) {
12
+ cout<<"\n i = "<<i;
13
+ i++;
14
+ }
15
+
16
+ return 0;
17
+ }
Additional algorithm 22b.cpp ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 22. Here the positive increment while-loop structure is demonstrated. A variable i is declared and set to zero. A while loop structure increments variable i from its initial value to its upper limit (number five). At each iteration, variable i is printed in the output. The result is an enumeration of values from 0 to 4. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ int i = 0;
10
+
11
+ do {
12
+ cout<<"\n i = "<<i;
13
+ i++;
14
+ }
15
+ while (i < 5);
16
+
17
+ return 0;
18
+ }
Additional algorithm 23.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 23. It demonstrates the traversal of a one-dimensional array. An array variable is declared with string literals. The implementation also uses two other variables. A variable t stores string values and is initially set to empty. Another variable (ie. i) initialized with value zero is the counter of a while-loop. The while-loop traverses the elements of array A by using the counter i as an index. At each iteration, the value from an element is added together with other string characters to the variable t. Once the end of the while-loop cycle is reached, the value collected in the variable t is printed in the output for inspection. Note that the source code is in context and works with copy/paste.
3
+
4
+ A = ["a", "b", "c", "d", "e", "f", "g"]
5
+
6
+ i = 0
7
+ t = ''
8
+
9
+ while i <= len(A)-1:
10
+ t += "\n i[" + str(i) + "]=" + str(A[i])
11
+ i += 1
12
+
13
+ print(t)
Additional algorithm 23a.cpp ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 23. It demonstrates the traversal of a one-dimensional array. An array variable is declared with string literals. The implementation also uses two other variables. A variable t stores string values and is initially set to empty. Another variable (ie. i) initialized with value zero is the counter of a while-loop. The while-loop traverses the elements of array A by using the counter i as an index. At each iteration, the value from an element is added together with other string characters to the variable t. Once the end of the while-loop cycle is reached, the value collected in the variable t is printed in the output for inspection. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[] = {"a", "b", "c", "d", "e"};
10
+ int n = sizeof(A) / sizeof A[0];
11
+
12
+ int i = 0;
13
+ string t = "";
14
+
15
+ while (i < n) {
16
+ t += "\n i[" + to_string(i);
17
+ t += "]=" + A[i];
18
+ i++;
19
+ }
20
+
21
+ cout<<t;
22
+ return 0;
23
+ }
Additional algorithm 23b.cpp ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 23. It demonstrates the traversal of a one-dimensional array. An array variable is declared with string literals. The implementation also uses two other variables. A variable t stores string values and is initially set to empty. Another variable (ie. i) initialized with value zero is the counter of a while-loop. The while-loop traverses the elements of array A by using the counter i as an index. At each iteration, the value from an element is added together with other string characters to the variable t. Once the end of the while-loop cycle is reached, the value collected in the variable t is printed in the output for inspection. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[] = {"a", "b", "c", "d", "e"};
10
+ int n = sizeof(A) / sizeof A[0];
11
+
12
+ int i = 0;
13
+ string t = "";
14
+
15
+ do {
16
+ t += "\n i[" + to_string(i);
17
+ t += "]=" + A[i];
18
+ i++;
19
+ }
20
+ while (i < n);
21
+
22
+ cout<<t;
23
+ return 0;
24
+ }
Additional algorithm 24.cpp ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 24. The for-loop cycle for incrementing some simple variables is demonstrated. Specifically, two variables a and b are declared and initialized. The variable a is initialized to the integer five and the variable b is set to zero. The for-loop is then declared to start at the initial value of i and end at the value indicated by variable a. At each increment, the value in variable i is added to the numeric value stored in variable b. At the end of the loop, the final value stored in variable b is printed to the output for inspection. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ int a = 5;
10
+ int b = 0;
11
+
12
+ for (int i = 0; i < a; i++) {
13
+ b += i;
14
+ }
15
+
16
+ cout<<b;
17
+ return 0;
18
+ }
Additional algorithm 24.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 24. The for-loop cycle for incrementing some simple variables is demonstrated. Specifically, two variables a and b are declared and initialized. The variable a is initialized to the integer five and the variable b is set to zero. The for-loop is then declared to start at the initial value of i and end at the value indicated by variable a. At each increment, the value in variable i is added to the numeric value stored in variable b. At the end of the loop, the final value stored in variable b is printed to the output for inspection. Note that the source code is in context and works with copy/paste.
3
+
4
+ a = 5
5
+ b = 0
6
+
7
+ for i in range(0, a):
8
+ b += i
9
+
10
+ print (b)
Additional algorithm 25.cpp ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 25. It demonstrates the use of a for-loop for the traversal of a one-dimensional array. An array variable is declared with string literals. The implementation also uses two other variables. A variable t stores string values and is initially set to empty. Another variable (ie. i) initialized with value zero is the counter of a for-loop. The for-loop traverses the elements of array A by using the counter i as an index. At each iteration, the value from an element is added together with other string characters to the content of variable t. Once the end of the for-loop cycle is reached, the value collected in variable t is printed in the output for inspection. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[] = {"a","b","c","d","e"};
10
+ string t = "";
11
+
12
+ int n = sizeof(A) / sizeof A[0];
13
+
14
+ for (int i = 0; i < n; i++) {
15
+
16
+ t += "A["+to_string(i)+"]=";
17
+ t += A[i]+"\n";
18
+ }
19
+
20
+ cout<<t;
21
+
22
+ return 0;
23
+ }
Additional algorithm 25.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 25. It demonstrates the use of a for-loop for the traversal of a one-dimensional array. An array variable is declared with string literals. The implementation also uses two other variables. A variable t stores string values and is initially set to empty. Another variable (ie. i) initialized with value zero is the counter of a for-loop. The for-loop traverses the elements of array A by using the counter i as an index. At each iteration, the value from an element is added together with other string characters to the content of variable t. Once the end of the for-loop cycle is reached, the value collected in variable t is printed in the output for inspection. Note that the source code is in context and works with copy/paste.
3
+
4
+ A = ["a", "b", "c", "d", "e"]
5
+
6
+ i = 0
7
+ t = ''
8
+
9
+ for i in range(0, len(A)):
10
+ t += "\n A[" + str(i) + "]=" + str(A[i])
11
+
12
+ print (t)
Additional algorithm 26.cpp ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 26. It demonstrates the use of nested for-loops. It shows the traversal of a two-dimensional array by a nested for-loop structure. A 2D-array variable (A) is declared with mixed datatypes, namely with string literals and number literals. A string variable t is initially set to empty. Another two variables (ie. i and j) are initialized with value zero and are the main counters of nested for-loops. The upper limit of each for-loop is established by the two dimensions, namely the number of rows and columns from matrix A. The two for-loops traverse the elements of array A by using the counters i and j as an index. At each iteration, the value from an element is added to the content of variable t. Once the end of the nested for-loops is reached, the value collected in variable t is printed in the output for inspection. The end result is the enumeration of each value in the output, in a linear manner. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[][2] = {
10
+ {"a","b"},
11
+ {"c","d"},
12
+ {"e","f"},
13
+ {"g","h"},
14
+ };
15
+ string t = "";
16
+
17
+ int n = sizeof(A) / sizeof A[0];
18
+ int m = sizeof A[0] / sizeof(string);
19
+
20
+ for (int i = 0; i < n; i++) {
21
+ for (int j = 0; j < m; j++) {
22
+
23
+ t += "A["+to_string(i);
24
+ t += "]["+to_string(j);
25
+ t += "]="+A[i][j]+"\n";
26
+ }
27
+ }
28
+ cout<<t;
29
+
30
+ return 0;
31
+ }
Additional algorithm 26.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 26. It demonstrates the use of nested for-loops. It shows the traversal of a two-dimensional array by a nested for-loop structure. A 2D-array variable (A) is declared with mixed datatypes, namely with string literals and number literals. A string variable t is initially set to empty. Another two variables (ie. i and j) are initialized with value zero and are the main counters of nested for-loops. The upper limit of each for-loop is established by the two dimensions, namely the number of rows and columns from matrix A. The two for-loops traverse the elements of array A by using the counters i and j as an index. At each iteration, the value from an element is added to the content of variable t. Once the end of the nested for-loops is reached, the value collected in variable t is printed in the output for inspection. The end result is the enumeration of each value in the output, in a linear manner. Note that the source code is in context and works with copy/paste.
3
+
4
+ A = [["a", 88, 146],
5
+ ["b", 34, 124],
6
+ ["c", 96, 564],
7
+ [100, 12, "d"]]
8
+
9
+ t = ""
10
+
11
+ for i in range(0, len(A)):
12
+ for j in range(0, len(A[i])):
13
+ t += "\n A[" + str(i) + "]["
14
+ t += str(j) + "]=" + str(A[i][j])
15
+
16
+ print(t)
Additional algorithm 27.cpp ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 27. It demonstrates the use of a single for-loop for two-dimensional arrays. It shows the traversal of a two-dimensional array by one for-loop structure. A 2D-array variable (A) is declared with mixed datatypes as before, namely with string literals and number literals. A string variable t is initially set to empty. A variable v is set to zero and it represents the main counter of the for-loop. Another two variables (ie. i and j) are initialized with value zero and are the main coordinates for element identification. Each dimension of array A is stored in variables n and m, namely the number of rows in n and the number of columns in m. The upper limit of the for-loop is calculated based on the two known dimensions n and m. Thus, m times n establishes the upper limit of the for-loop. Here, the value of the counter v from the for-loop is used to calculate the i and j values that are used as an index to traverse the array variable A. The value of variable j is computed as the v % m and the result of this expression indicates the reminder (ex. 5 mod 3 is 2). The secret to this implementation is a condition that increments a variable i (rows) each time j (columns) equals zero. Thus, in this manner this approach provides the i and j values that a nested for-loop provides. At each iteration, the value from an element is added to the content of variable t. Once the end of the for-loop is reached, the value collected in variable t is printed in the output for inspection. The end result is the enumeration of each value in the output, in a linear manner. Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ string A[][2] = {
10
+ {"a","b"},
11
+ {"c","d"},
12
+ {"e","f"},
13
+ {"g","h"},
14
+ };
15
+ string t = "";
16
+
17
+ int n = sizeof(A) / sizeof A[0];
18
+ int m = sizeof A[0] / sizeof(string);
19
+
20
+ int i = 0;
21
+ int j = 0;
22
+
23
+ for (int v = 0; v < n*m; v++) {
24
+
25
+ j = v % m;
26
+ if(v!=0 && j == 0){i++;}
27
+
28
+ t += to_string(v);
29
+ t += " A["+to_string(i)+"][";
30
+ t += to_string(j)+"]=";
31
+ t += A[i][j] + "\n";
32
+ }
33
+ cout<<t;
34
+
35
+ return 0;
36
+ }
Additional algorithm 27.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 27. It demonstrates the use of a single for-loop for two-dimensional arrays. It shows the traversal of a two-dimensional array by one for-loop structure. A 2D-array variable (A) is declared with mixed datatypes as before, namely with string literals and number literals. A string variable t is initially set to empty. A variable v is set to zero and it represents the main counter of the for-loop. Another two variables (ie. i and j) are initialized with value zero and are the main coordinates for element identification. Each dimension of array A is stored in variables n and m, namely the number of rows in n and the number of columns in m. The upper limit of the for-loop is calculated based on the two known dimensions n and m. Thus, m times n establishes the upper limit of the for-loop. Here, the value of the counter v from the for-loop is used to calculate the i and j values that are used as an index to traverse the array variable A. The value of variable j is computed as the v % m and the result of this expression indicates the reminder (ex. 5 mod 3 is 2). The secret to this implementation is a condition that increments a variable i (rows) each time j (columns) equals zero. Thus, in this manner this approach provides the i and j values that a nested for-loop provides. At each iteration, the value from an element is added to the content of variable t. Once the end of the for-loop is reached, the value collected in variable t is printed in the output for inspection. The end result is the enumeration of each value in the output, in a linear manner. Note that the source code is in context and works with copy/paste.
3
+
4
+ A = [["a", 88, 146],
5
+ ["b", 34, 124],
6
+ ["c", 96, 564],
7
+ [100, 12, "d"]]
8
+
9
+ t = ""
10
+ n = len(A) # rows
11
+ m = len(A[0]) # columns
12
+
13
+ i = 0
14
+ j = 0
15
+
16
+ for v in range(0, n*m):
17
+ j = v % m
18
+ if(v != 0 and j == 0):
19
+ i = i + 1
20
+ t += str(v) + " A[" + str(i) + "]["
21
+ t += str(j) + "]=" + str(A[i][j]) + "\n"
22
+
23
+ print(t)
Additional algorithm 28.cpp ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 28. It demonstrates the use of a single for-loop for three-dimensional arrays, with an extrapolation to multidimensional arrays. Note that the example shown here is done only for Javascript in order to preserve paper. One can port this in any other language as previously shown. The traversal of a 3D array using only one for-loop structure, is based on the previous example. A 3D-array variable (A) is declared with mixed datatypes, namely with string literals and number literals. The 3D-array is represented by five matrices, in which the columns represent one dimension, the rows represent the second dimension, and the number of matrices, represents the third dimension. Thus, this array can be understood as a cube-like structure. A string variable t is initially set to empty. A variable v is set to zero and it represents the main counter of the for-loop. Another three variables (ie. i, j and d) are initialized with a value of zero and are the main coordinates for array element identification. Each dimension of array A is stored in variables s, m and n, namely the number of matrices in s, the number of rows in m and the number of columns in n. The upper limit of the for-loop is calculated as s × m × n. Here, the value of the counter v from the for-loop is used, as before, to calculate the i, j and d values that are used as an index to traverse the array variable A. The value of variable j is computed as the v % m. A condition increments a variable i (rows) each time j (columns) equals zero. Thus, both i and j values are computed. However, the value for variable d (matrix number) is calculated as v % (m×n), which provides a value of zero each time a matrix was traversed. Thus, a condition increments variable d and resets variable i, each time the value of k equals zero. At each iteration, the value from an element (d, i, j) is added to the content of variable t. Once the end of the for-loop is reached, the string value collected in variable t is printed in the output for inspection. The end result is the enumeration of each value in the output, in a linear manner. Note that the source code is in context and works with copy/paste.
3
+
4
+ // this example was provided only in Javascript
Additional algorithm 28.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 28. It demonstrates the use of a single for-loop for three-dimensional arrays, with an extrapolation to multidimensional arrays. Note that the example shown here is done only for Javascript in order to preserve paper. One can port this in any other language as previously shown. The traversal of a 3D array using only one for-loop structure, is based on the previous example. A 3D-array variable (A) is declared with mixed datatypes, namely with string literals and number literals. The 3D-array is represented by five matrices, in which the columns represent one dimension, the rows represent the second dimension, and the number of matrices, represents the third dimension. Thus, this array can be understood as a cube-like structure. A string variable t is initially set to empty. A variable v is set to zero and it represents the main counter of the for-loop. Another three variables (ie. i, j and d) are initialized with a value of zero and are the main coordinates for array element identification. Each dimension of array A is stored in variables s, m and n, namely the number of matrices in s, the number of rows in m and the number of columns in n. The upper limit of the for-loop is calculated as s × m × n. Here, the value of the counter v from the for-loop is used, as before, to calculate the i, j and d values that are used as an index to traverse the array variable A. The value of variable j is computed as the v % m. A condition increments a variable i (rows) each time j (columns) equals zero. Thus, both i and j values are computed. However, the value for variable d (matrix number) is calculated as v % (m×n), which provides a value of zero each time a matrix was traversed. Thus, a condition increments variable d and resets variable i, each time the value of k equals zero. At each iteration, the value from an element (d, i, j) is added to the content of variable t. Once the end of the for-loop is reached, the string value collected in variable t is printed in the output for inspection. The end result is the enumeration of each value in the output, in a linear manner. Note that the source code is in context and works with copy/paste.
3
+
4
+ # this example was provided only in Javascript
Additional algorithm 29.cpp ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 29. It shows the use of functions that take simple arguments. An integer literal is assigned to a variable a. Variable a is then used as an argument for a function called "compute". Function "compute" takes the argument and uses its value in a mathematical expression. The returned value of function "compute" is then assigned to a variable b, which is then printed into the output for inspection. Note that the source code is in context and works with copy/paste.
3
+
4
+ int compute(int x)
5
+ {
6
+ return x + x / x - x * x;
7
+ }
8
+
9
+ int main()
10
+ {
11
+ int a = 10;
12
+ int b = compute(a);
13
+
14
+ cout<<b;
15
+
16
+ return 0;
17
+ }
Additional algorithm 29.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ #Additional algorithm 29. It shows the use of functions that take simple arguments. An integer literal is assigned to a variable a. Variable a is then used as an argument for a function called "compute". Function "compute" takes the argument and uses its value in a mathematical expression. The returned value of function "compute" is then assigned to a variable b, which is then printed into the output for inspection. Note that the source code is in context and works with copy/paste.
3
+
4
+ def compute(x):
5
+ return x + x / x - x * x
6
+
7
+ a = 10
8
+ b = compute(a)
9
+ print(b)
Additional algorithm 3.cpp ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
2
+ //Additional algorithm 3. The first line of each computer language in the above list, shows an extraction of an ASCII character on the basis of an ASCII code. The second line shows the extraction of the ASCII code based on a given ASCII character. The output for any of the above statements is "Code 65 is the:'A' letter" and "Letter A has the code:'65'". Note that the source code is in context and works with copy/paste.
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ int main()
8
+ {
9
+ cout<<"Code 65 is the:'"<<(char) 65<<"' letter\n";
10
+ cout<<"Letter A has the code:'"<<(int) 'A'<<"'";
11
+
12
+ return 0;
13
+ }