Posts

Showing posts from 2018

Ada Loop Tutorial

The Ada programming language provides four different looping constructs; the “for” loop, the “while” loop, the simple loop and the container iterator loop. The For loop The Ada “for” loop iterates over a range of discrete values. Ada discrete values include signed integer values, modular (unsigned) integer values, and enumeration values. Ada ranges are always specified as lowest_value..highest value. Every “for” loop has a loop variable which is NOT declared before it is used. The loop variable has the type of the loop range. The loop variable cannot be altered within the body of the loop. Ranges are always specified as lowest_value..highest_value, even if one wants to iterate through the range in reverse order. Any range where the first value is greater than the last value is considered an empty range. To iterate through a range in reverse order simply add the “reverse” reserved word For Num in reverse 1..10 loop Example For loop with ...

Comparison of Simple Matrix Code in C and Ada

Summary A matrix is a two dimensional array of elements. Matrices are commonly used to represent spread sheets or tables of information. A square matrix is a matrix with the same number of rows and columns. A square matrix is said to be symmetric if the transpose of the matrix is equal to the original matrix. Only square matrices can be symmetric. The website https://www.studytonight.com/c/programs/array/check-square-matrix-is-symmetric-or-not provides an example of a C program to determine if a square matrix input by the user is symmetric or not. The source code for the C program can be viewed through the link shown above. Remarks concerning the C code The code works very well within limits. The limits of its proper behavior are defined by the declaration of the arrays found on line 7 of the C source code. int c, d, a[10][10], b[10][10], n, temp; Two matrices are declared. Both matrices have a dimension of 10. While 10 may be a useful arbitrary ...

Ada Pre and Post Conditions

Ada preconditions and post-conditions are implemented using aspect clauses. While aspect clauses can include many other terms used to specify program behavior, this posting will focus on preconditions and post-conditions. A thorough discussion of preconditions and post-conditions can be found at http://www.ada-auth.org/standards/12rat/html/Rat12-2-3.html Since its first official version in 1983 the Ada language has always allowed the programmer to define data types and subtypes with specific ranges. For example: type Byte is range -2**7..2**7 – 1;          -- signed integer type type Unsigned_Byte is mod 2**8;              -- modular type type Normalized is digits 5 range 0.0..1.0; -- floating point type type Money is digits 10 delta 0.01;          -- decimal fixed point type subtype Uppers is Character...