-- Sample to demonstrate arrays array1.adb with Ada.Text_IO ; use Ada.Text_IO ; procedure Array1 is -- dimension the array Balances with subscripts ranging form 1 to 20 -- and having each element of the array be a floating point number Balances : array ( 1..20 ) of Float := ( 1 .. 20 => 0.0 ) ; -- declare the variable Open_Accounts to be integer and initialized -- to zero. This will be the number of entries used in the array. Open_Accounts : INTEGER := 0 ; package INT_IO is new Integer_IO ( Integer ) ; use INT_IO ; package FLT_IO is new Float_IO ( Float ) ; use FLT_IO ; begin -- zero out the array in execution, redundant, just for demonstration for I in 1 .. 20 loop Balances ( I ) := 0.0 ; end loop ; -- increment the array index and put in data Open_Accounts := Open_Accounts + 1 ; Balances ( Open_Accounts ) := 1.5 ; -- any integer expression can be used as a subscript Balances ( Open_Accounts + 1 ) := 0.732_175E6 ; -- note: floating point numbers can use scientific notation -- but be sure to use at least one digit before and after the point Put ( Open_Accounts ) ; Put_Line ( " open accounts " ) ; Put ( Balances ( Open_Accounts ) ) ; Put_Line ( " is balance, no formatting " ) ; Put ( Balances ( Open_Accounts ) , Fore => 5 , Aft => 2 , Exp => 0 ) ; Put_Line ( " is balance, named parameters " ) ; Put ( Balances ( Open_Accounts ) , 5 , 2 , 0 ) ; Put_Line ( " is balance, positional parameters " ) ; end Array1 ; -- 1 open accounts -- 1.50000E+00 is balance, no formatting -- 1.50 is balance, named parameters -- 1.50 is balance, positional parameters