Unit II - Structuring Data, Computations and Programming
Unit II - Structuring Data, Computations and Programming
Programming
Structuring of Data- Built in and primitive types, Data
aggregates and type constructors, Cartesian product,
Finite mapping User -defined types and abstract data
types,
Type systems, Static versus dynamic program checking,
Strong typing and type checking, Type compatibility,
Type conversions, Types and subtypes, Generic types,
monomorphic versus polymorphic type systems,
Structuring of Computations: Structuring the
computation, Expressions and statements,
Conditional execution and iteration, Routines, Style
Computer programs can be viewed as functions that are applied to values of
certain input domains to produce results in some other domains.
Data structuring gives immense strength throughout the programming and
programs.
i.e. nothing but the functions are evaluated through a sequence of steps that
produce intermediate data that stored in program variables.
Languages do so by providing features to describe data, the flow of
computation, and the overall program organization.
Programming languages organize data through the concept of type. Classify
data according to different categories.
A type is thus more properly defined as a set of values and a set of operations
that can be used to manipulate them.
For example, the type BOOLEAN of languages like Ada and Pascal consists of
the values TRUE and FALSE;
Boolean algebra defines operators NOT, AND, and OR for BOOLEANs.
BOOLEAN values may be created, for example, as a result of the application of
relational operators (<, ð, >, Š, +, ¦) among INTEGER expressions.
Elementary Data Types
An elementary data types contains a single data values and class of such
data objects over which various operations.
Some elementary data types: Integer, real, character, Boolean,
enumeration and pointer.
1. Attributes – Basic attributes of any data object, such as data type and
name are usually invariant during its lifetime.
2. Values - The type of data object determines the set of possible values
that it
may contain.
3. Operations – The set of operations defined by language is basically refers
that how data object of that data type may be manipulated.
Built-in types and primitive types
Any programming language is equipped with a finite set of built-in types
(or predefined) types, which normally reflect the behavior of the
underlying hardware.
At the hardware level, values belong to the untyped domain of bit strings,
which constitutes the underlying universal domain of computer data.
At the hardware level, a type may thus be considered as a view under
which data belonging to the universal type may be manipulated.
As an example,the bit string "01001010" might be interpreted as integer
"74" (coded intwo’s complement representation) when it is the argument
of the machineinstruction ADD (which does integer addition).
However, it would be interpreted as a bit string by the machine instruction
CPL (which does bitwise complement).
It might be interpreted as ASCII character "I" if printed by instruction PCH
(which prints an ASCII character).
The built-in types of a programming language reflect the different views
provided by typical hardware. Examples of built-in types are:
• booleans, i.e., truth values TRUE and FALSE, along with the set of operations
defined byBoolean algebra;
• characters, e.g., the set of ASCII characters;
• integers, e.g., the set of 16-bit values in the range <-32768, 37767>; and
• reals, e.g., floating point numbers with given size and precision.
Primitive data types may refer to the standard data types built into a
programming language (built-in types).
Primitive is the most fundamental data type usable in the Programming
language.
There are eight primitive data types: Boolean, byte, character, short, int,
long, float, and double.
In a Programming language, these data types serve as the foundation for data
manipulation.
All basic data types are built-in into the majority of programming languages.
Primitive data types may or may not have a one-to-one correspondence with
objects in the computer's memory, depending on the language and its
implementation.
For example, integer addition can be performed as a single machine
instruction, and some processors provide specific instructions for processing