Previous topic |
Ada Home Page |
Index
FOR example
----------------------------------------------------------
-- squares.adb - produce a table of squares
-- Skansholm pp57-58
----------------------------------------------------------
with TEXT_IO; use TEXT_IO;
procedure squares is
-- declare integer I/O library
package int_io is new TEXT_IO.INTEGER_IO( INTEGER );
use int_io;
-- declare any constants and variables required
table_size: integer; -- size of table to produce
----------------------------------------------------------
-- squares program code
----------------------------------------------------------
begin -- squares
-- get table size from user
PUT_LINE ("Give the size of the table: ");
GET (table_size); SKIP_LINE;
-- generate and display table of squares
NEW_LINE;
PUT_LINE ("Number Square"); NEW_LINE;
for number in 1..table_size loop
PUT (number, width=>4);
PUT (number * number, width=>10); NEW_LINE;
end loop;
end squares;
Previous topic |
Ada Home Page |
Index
c-lokan@adfa.oz.au / 13 Feb 96