How to fix the following procedures so that the parameters act as in out mode parameters?
3 December 2022 at 01:29
Please solve this in ADA:
--initialize first array (My_Array) with random binary values
procedure Init_Array (Arr : BINARY_ARRAY) is
package Random_Bit is new Ada.Numerics.Discrete_Random (BINARY_NUMBER);
use Random_Bit;
G : Generator;
begin
Reset (G);
for Index in 1..16 loop
Arr(Index) := Random(G);
end loop;
end Init_Array;
--reverse binary array
procedure Reverse_Bin_Arr (Arr : BINARY_ARRAY) is
hold : BINARY_ARRAY := Arr;
begin
for Index in 1..16 loop
Arr(15 - Index) := hold(Index);
end loop;
end Reverse_Bin_Arr;
--initialize first array (My_Array) with random binary values
procedure Init_Array (Arr: in out BINARY_ARRAY);
--reverse binary array
procedure Reverse_Bin_Arr (Arr : in out BINARY_ARRAY);
I believe my above procedures are correct. I just keep getting the following error:
assgn.adb:7:15: not fully conformant with declaration at assgn.ads:7
assgn.adb:7:15: mode of "Arr" does not match
assgn.adb:19:15: not fully conformant with declaration at assgn.ads:10
assgn.adb:19:15: mode of "Arr" does not match
gnatmake: "assgn.adb" compilation error
The first procedure should initialize a random array that houses each bit of a binary number. Example: [1,0,1,0,1,1,1,1,0,0,0,1,1,0,1,0]
The second procedure should reverse the bits in the binary array.