Read, predict, and change your first Ada program · 3 Lessons
English

Ada Engineering

Module 1 – Read, predict, and change your first Ada program

Page 1 of 3 · About 15 minutes per lesson, including practice.

A program is a sequence you can explain

A program gives a computer precise instructions. In this example, with Ada.Text_IO; makes a standard input/output package available. Main names the procedure we run. Declarations come before begin; the statements after it execute in order. The -- marker starts a comment if you want to add your own explanation.

with Ada.Text_IO;

procedure Main is
   Lessons_Done : Natural := 0;
begin
   Ada.Text_IO.Put_Line ("My first Agila study session");
   Lessons_Done := Lessons_Done + 1;
   if Lessons_Done = 1 then
      Ada.Text_IO.Put_Line ("One lesson completed");
   end if;
end Main;

Predict the two printed lines before running. Lessons_Done begins at zero, then becomes one. := assigns a value; = compares values. Text between double quotes is a string. A successful build means the compiler accepted this program; it does not establish that it solves your intended problem.

Reference: AdaCore: imperative language.

Example code on Agila Forge ↗

Complete this lesson

Answer every check correctly to earn your lesson certificate. Feedback helps you review and try again.

Sign in · Save your progress and earn a certificate for this lesson.