-- Chapter 9 - Program 3 with Ada.Text_IO, Ada.Integer_Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO; procedure Blocks is Index, Count : INTEGER; begin Index := 27; Count := 33; Put("In the main block - values are"); Put(Index, 5); -- Blocks.Index Put(Count, 5); -- Blocks.Count New_Line; declare Index, Stuff : INTEGER := -345; begin Index := 157; Put("In the embedded block - values are"); Put(Blocks.Index, 5); -- Blocks.Index Put(Index, 5); -- local Index Put(Stuff, 5); -- local Stuff Put(Count, 5); -- Blocks.Count New_Line; end; Put("Back to the main block - values are"); Put(Index, 5); -- Blocks.Index Put(Count, 5); -- Blocks.Count New_Line; Who: -- Block name declare Index, Stuff : INTEGER := -345; begin Index := 157; Put("In the block named Who - values are"); Put(Blocks.Index, 5); -- Blocks.Index Put(Index, 5); -- Who.Index Put(Who.Index, 5); -- Who.Index Put(Stuff, 5); -- Who.Stuff Put(Who.Stuff, 5); -- Who.Stuff Put(Count, 5); -- Blocks.Count New_Line; end Who; Put("Back to the main block - values are"); Put(Index, 5); -- Blocks.Index Put(Count, 5); -- Blocks.Count New_Line; end Blocks; -- Result of execution -- In the main block - values are 27 33 -- In the embedded block - values are 27 157 -345 33 -- Back to the main block - values are 27 33 -- In the block named Who - values are 27 157 157 -345 -345 33 -- Back to the main block - values are 27 33