Chapter 1 Examples

 

-- ***************************************************************************
-- *                         Hello_World.adb 
-- * Copyright (c) Simon Johnston & Addison Wesley Longman 1996.
-- *
-- * Description: This is an example of what an example looks like, taken
-- *    from the introduction chapter.
-- * Inputs:  None.
-- * Outputs: will write the contents of the constant string "Message" to 
-- *    the standard output stream.
-- ***************************************************************************
with Ada.Text_IO;
use  Ada.Text_IO;
procedure Hello_World is
   Message : constant String := "Hello World";
begin
   Put_Line(Item => Message);
end Hello_World;

 

-- ***************************************************************************
-- *                         Simple_Math.adb 
-- * Copyright (c) Simon Johnston & Addison Wesley Longman 1996.
-- *
-- * Description: This is an example of some more complex I/O.
-- * Inputs:  None.
-- * Outputs: will write the result of a simple calculation to the standard 
-- *    output stream.
-- ***************************************************************************
with Ada.Text_IO;
use  Ada.Text_IO;
with Ada.Integer_Text_IO;
use  Ada.Integer_Text_IO;
procedure Simple_Math is
   Result : Integer;
begin
   Result := 2 + 2;
   Put("The result of 2 + 2 is ");
   Put(Result);
   New_Line;
end Simple_Math;

Contents Page

Copyright © 1996 Simon Johnston &
Addison Wesley Longman