Array length: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 167: | Line 167: | ||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
<syntaxhighlight lang="ada"> |
<syntaxhighlight lang="ada"> |
||
with Ada.Text_IO; use Ada.Text_IO; |
|||
with System; |
|||
procedure Array_Length is |
procedure Array_Length is |
||
Fruits : constant array (Positive range <>) of access constant String |
Fruits : constant array (Positive range <>) of access constant String |
||
:= (new String'("orange"), |
:= (new String'("orange"), |
||
new String'("apple")); |
new String'("apple")); |
||
Memory_Size : constant Integer := Fruits'Size / System.Storage_Unit; |
|||
⚫ | |||
for Fruit of Fruits loop |
|||
Ada.Text_IO.Put (Integer'Image (Fruit'Length)); |
|||
end loop; |
|||
⚫ | |||
⚫ | |||
Put_Line ("Number of elements : " & Fruits'Length'Image); |
|||
⚫ | |||
Put_Line (" " & Integer'Image (Memory_Size * System.Storage_Unit / System.Word_Size) & " words" ); |
|||
end Array_Length;</syntaxhighlight> |
end Array_Length;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
|||
<pre> 6 5 Array Size: 2</pre> |
|||
Number of elements : 2 |
|||
Array memory Size : 32 bytes |
|||
4 words |
|||
</pre> |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |