Debian Codegraph @

examples/book/digital-artists/chapter5/Listing5.12.ck

raw
1 // Listing 5.12 Functions on arrays
2
3 // (1) global note array
4 [60,62,63,65,67,69,70,72] @=> int scale[];
5 // function to modify an element of an array
6 fun void arrayAdder( int temp[], int index)
7 { // (2) arrayAdder function to modify it
8 1 +=> temp[index];
9 }
10
11 // test it all out
12 <<< scale[0], scale[1], scale[2], scale[3] >>>;
13
14 arrayAdder(scale, 2);
15 <<< scale[0], scale[1], scale[2], scale[3] >>>;
16 <<< "scale[6] = ", scale[6] >>>;
17
18 arrayAdder(scale, 6);
19 <<< "scale[6] = ", scale[6] >>>;