code-examples/2015/2015_03/ada/nauka/cond_structures2/hello.adb

62 lines
1.2 KiB
Ada
Raw Normal View History

2025-03-09 10:58:55 +00:00
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Command_Line;
use Ada.Command_Line;
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;
procedure Hello is
package IO renames Ada.Text_IO;
i: Integer := 2;
j: Integer := 1;
k: Integer;
procedure Add (A, B: in Integer; C: out Integer) is
begin
C := A + B;
end Add;
function Subtract(A, B: Integer) return Integer is
begin
return A - B;
end Subtract;
function Factorial(X: Integer) return Integer is
begin
if x <= 1 then
return 1;
end if;
return X * Factorial(X-1);
end Factorial;
begin
Put_Line("Hello, world");
Add(i,j,k);
k := Subtract(k,1);
case k is
when 1 =>
Put_Line("i ma wartosc 1");
when 2 =>
Put_Line("i ma wartosc 2");
when 3 =>
Put_Line("i ma wartosc 3");
when others =>
Put_Line("i ma niespotykaną wartość");
end case;
New_Line(1);
Put("Ala ma ");
Put(Factorial(5),0);
Put(" kotów");
New_Line;
K := Integer(2.4);
Put("Skonwertowane 2.5 to: ");
Put(K,0);
New_Line;
end Hello;