Data Manipulation in Programming
Data Manipulation in Programming
IN PROGRAMMING
DSALGO
Statements
• A program is a representation of an algorithm, suitable for computer execution.
• The computer translates the program and then executes it
• A statement is the elementary component of the program
• A program statement is analogous to a sentence in a natural language
• Either executable or non executable
Executable statements
• Orders for an action to be taken by the CPU of the computer during the execution
of the program.
• Imperative
• Translated by software translators into one or more machine language
intstructions
Nonexecutable statements
• Orders to the language translators or other system programs and do not produce
machine language instructions to be incorporated in the object program
• Descriptive
• Serves to allocate memory space for the data utilized by the program
• The action of an executable statement is reflected as a change of value of an item
of data.
• Input data are transformed by the program, after intermediate stages, into output
data.
Data type?
• Is an interpretation applied to a set of bits representing a given data item
• Operations that may be applied to a data item depend on its type.
Simple data types
• Integer – signed number with no fractional part
• Real – a signed number with an integer and a fractional part
• Logical (Boolean) – data type with only two possible values: TRUE and FALSE
• Used to represent the conditions which underlie decisions as to the flow of control
• Character – alphabetic or numerical digit or a special symbol
• Organized into sequences called strings
• Used to manipulate text
Constants and variables
• Constant – a data item that remains unchanged throughout the computation
based on an algorithm and is, therefore, specified by its value, which is used
directly in an algorithm or a program
• Variable – named data item
• The value may change during the execution of the program
Start
Example: Input 2
add two integers
integers
and Add up 2 integers
present
the sum Output sum
Stop
• The ability to use variables differentiates computers from rudimentary calculators.
• Their use makes it possible to postpone presenting actual values until the
appropriate point during the program execution
• Variable names are assigned by the programmer according to the conventions of a
given programming language
Arrays
• Collection of data items of the same type referred to collectively by a single name
• Individual data items called array elements, are ordered by their
subscripts/indexes
• The number of subscripts of an array determines its dimensionality
Declarations
• Provides information to the language translator concerning the type of variables
and, in the case of structured data, the structure
• Using this information, the translators and other systems software are able to
allocate memory space for the data
• Once a variable has been declared in such a statement, it may be subsequently
referenced in the program by its name
Input and output
• I/O that transfer a single value are elementary operations in higher level
programming languages
• Input, the value is presented to the computer by the input device
• Output, presented by the computer through the output device