Imperative language

Hello World

Your goal with this exercise is to create an application that displays the message "Hello World!".

with Ada.Text_IO; use Ada.Text_IO; procedure Main is begin -- Implement the application here! null; end Main;

Greetings

Your goal with this exercise is to create an application that, given a name (e.g. "John"), displays the message "Hello John!". In order to do this, you'll complete the Greet procedure.

  • Hint: you can use the concatenation operator (&).

For the moment, don't worry about the details of the Main procedure. You should just focus on implementing the application in the body of the Greet procedure.

with Ada.Command_Line; use Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; procedure Main is procedure Greet (Name : String) is begin -- Implement the application here! null; end Greet; begin if Argument_Count < 1 then Put_Line ("ERROR: missing arguments! Exiting..."); return; elsif Argument_Count > 1 then Put_Line ("Ignoring additional arguments..."); end if; Greet (Argument (1)); end Main;

Positive Or Negative

Your goal with this exercise is to create an application that, given an integer number X, classifies the number as positive, negative or zero and displays the result. In other words:

  1. If X > 0, display Positive.
  2. If X < 0, display Negative.
  3. If X = 0, display Zero.

You should focus on the Classify_Number procedure.

procedure Classify_Number (X : Integer);
with Ada.Text_IO; use Ada.Text_IO; procedure Classify_Number (X : Integer) is begin -- Implement the application here! null; end Classify_Number;
with Ada.Command_Line; use Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; with Classify_Number; procedure Main is A : Integer; begin if Argument_Count < 1 then Put_Line ("ERROR: missing arguments! Exiting..."); return; elsif Argument_Count > 1 then Put_Line ("Ignoring additional arguments..."); end if; A := Integer'Value (Argument (1)); Classify_Number (A); end Main;

Numbers

Your goal with this exercise is to create an application that, given two integer numbers, displays all numbers in the range starting with the smallest number.

For the moment, don't worry about the details of the Main procedure. You should just focus on implementing the application in the body of the Display_Numbers procedure.

procedure Display_Numbers (A, B : Integer);
procedure Display_Numbers (A, B : Integer) is begin -- Implement the application here! null; end Display_Numbers;
with Ada.Command_Line; use Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; with Display_Numbers; procedure Main is A, B : Integer; begin if Argument_Count < 2 then Put_Line ("ERROR: missing arguments! Exiting..."); return; elsif Argument_Count > 2 then Put_Line ("Ignoring additional arguments..."); end if; A := Integer'Value (Argument (1)); B := Integer'Value (Argument (2)); Display_Numbers (A, B); end Main;