Download presentation
Presentation is loading. Please wait.
Published byAlfred McCoy Modified over 9 years ago
2
Ada is a structured, statically typed, imperative, wide- spectrum, and object-oriented high-level computer programming language, extended from Pascal and other language created in the 1970 for the purpose of the US Department of defense this decision because they had realized that there were many languages used by the US Department of Defense and created this program to supersede the many different languages they were using
3
named after the first credited programmer Ada Lovelace the US Department of Defense was concerned by the number of different programming languages being used for its embedded computer system projects, many of which were obsolete or hardware-dependent, and none of which supported safe modular programming
4
Data types of a programming language are the different types of input and symbols that a programming language can read and work with
5
TypeRange Integer-2,147,483,648 to 2,147,483,647 Natural0 to Integer'last Positive1 to Integer'last Long_Integer-2**63 to (2**63)-1 Short_Integer-128 to 127 Float, Short_Float Real numbers with an approximate range of 8.43E-37 to 3.37E+38 and an accuracy of about 6 decimal digits Long_FloatReal numbers with an approximate range of 4.19E-307 to 1.67E+308 and an accuracy of about 15 decimal digits BooleanAn enumeration type with the values (False, True) CharacterA character in the ANSI (8-bit) character set. Wide_CharacterA character in the UNICODE (16-bit) character set Unsigned_Integer0 to 4,294,967,295 Byte_IntegerInteger values in the range of -128 to 127 Unsigned_Byte_IntegerInteger values in the range of 0 to 255 Word_IntegerInteger values in the range of -32768 to 32767 Unsigned_Word_IntegerInteger values in the range of 0 to 65535 Dword_IntegerInteger values in the range of -2,147,483,648 to 2,147,483,647 Unsigned_Dword_IntegerInteger values in the range of 0 to 4,294,967,295 Qword_Integer-2**63 to (2**63)-1 Byte_BooleanAn enumeration type with the values (False, True) Word_BooleanAn enumeration type with the values (False, True) Dword_BooleanAn enumeration type with the values (False, True). Useful when interfacing with C code.
6
Characternext_vowel := ‘o’; Floatdelta_v_sq := (v2-v1) **2; Delta_sum := (delta_v_sq + delta_h_sq) *.10; angle := 2.0 * pi * float(p) / 360.0; integeri := i + 1; naturalnew_value := abs(any_value) + mod(old_value, 10); string my_string := “ “ & packname(j) & “-“;
7
with Ada.Text_IO, ADa.Integer_Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO; procedure Example is Year : INTEGER; begin for Age in 0..21 loop Put("In"); Put(Age + 1938,5); Put(", I was"); Put(Age,3); Put(" years old"); case Age is when 5 => Put(", and started school"); when 17 => Put(", and graduated from high school"); when others => null; end case; Put("."); New_Line; end loop; end Example;
8
Parameter ModeFunctionsProcedureDescription INYes Passed into the subprogram, are constants in the subprogram, and may not be changed in the subprogram OUTNoYesPassed out of the subprogram, a parameters value is defined inside the subprogram INOUTNoYesPassed into the subprogram, and may be changed by the subprogram, and the parameters value is passed out of the subprogram
9
Although the Ada language primary use was for the US Department of Defense, it does support object oriented programming It does have use interface with buttons, images, audio, and other source of input
10
Concurrent computation makes programming much more complex major feature of the Ada programming language is the facilities it provides for concurrent programming
11
begin... exception when Buffer_Full_Error => Reset_Buffer; when Error: others => Put_Line("Unexpected exception raised:"); Put_Line(Ada.Exceptions.Exception_Information(Error)); end;
12
HELLO WORLD! -- Ada Hello, World! program. with Text_IO; use Text_IO; procedure Hello is Put_Line("Hello, World!"); end Hello;
13
Function: with Gnat.Io; use Gnat.Io; procedure f1 is -- A small function. function Sumsqr(X, Y: Integer) return Integer is begin return X*X + Y*Y; end; -- How 'bout a nice, tender variable? I: Integer; begin I := Sumsqr(3, 14); Put(I); New_Line; Put(Sumsqr(I, 4)); New_Line; end f1;
14
with Ada.Text_IO; use Ada.Text_IO; procedure ReadOut is S: String(1..100); -- Input line (up to 100 chars) N: Integer; -- Number of characters read. Begin -- Issue the lovely decoration. Put_Line("-----------------------------------------------------" & "-----------"); -- Copy lines like there's no tomorrow. loop Get_Line(S, N); Put_Line(S(1..N)); end loop; exception when End_Error => -- When reaching end of file, issue the closing lovely decoration and -- return from the procedure. Put_Line("-----------------------------------------------------" & "-----------"); return; end ReadOut;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.