에이다 (프로그래밍 언어): 두 판 사이의 차이
내용 삭제됨 내용 추가됨
잔글편집 요약 없음 |
편집 요약 없음 |
||
4번째 줄:
에이다는 컴퓨터 프로그래밍을 발명하는 데 공헌한 [[에이다 러브레이스]] (1815년-1852년)의 이름을 딴 것이다.
== 예 ==
==
언어의 [[구문]]의 일상적인 예로 들 수 있는 [[헬로 월드 프로그램]]:
<source lang="ada">
줄 13 ⟶ 14:
Ada.Text_IO.Put_Line("Hello, world!");
end Hello;
</source>
=== 자료형 ===
<source lang="ada">
type Day is range 1 .. 31;
type Month is range 1 .. 12;
type Year is range 1800 .. 2100;
type Date is
record
Day : Day;
Month : Month;
Year : Year;
end record;
</source>
=== 제어 구조 ===
<source lang="ada">
while a /= b loop
Ada.Text_IO.Put_Line ("Waiting");
end loop;
if a > b then
Ada.Text_IO.Put_Line ("Condition met");
else
Ada.Text_IO.Put_Line ("Condition not met");
end if;
for i in 1 .. 10 loop
Ada.Text_IO.Put ("Iteration: ");
Ada.Text_IO.Put (i);
Ada.Text_IO.Put_Line;
end loop;
loop
a := a + 1
exit when a = 10;
end loop;
case i is
when 0 => Ada.Text_IO.Put("zero");
when 1 => Ada.Text_IO.Put("one");
when 2 => Ada.Text_IO.Put("two");
end case;
</source>
=== 패키지, 프로시저, 함수 ===
<source lang="ada">
with Ada.Text_IO;
package Mine is
type Integer is range 1 .. 11;
i : Integer := Integer'First;
procedure Print (j: in out Integer) is
function Next (k: in Integer) return Integer is
begin
return k + 1;
end Next;
begin
Ada.Text_IO.Put_Line ('The total is: ', j);
j := Next (j);
end Print;
begin
while i < Integer'Last loop
Print (i);
end loop;
end Mine;
</source>
|