Sei sulla pagina 1di 7

CHAPTER 2: Concepts of Files

2.1 Files
In computer operations, a file is collection of related data that is created as a single unit on a
peripheral device. A file can be of following two types:

1. Master file

2. Transaction file

2.1.1 Contents of Master File


Master file: A file of related master records is a master file. Master record is data that is relatively
permanent; like name, sex, d.o.b.

2.1.2 Transaction file and its Organization

Transaction file: A transaction file is a file in which the current data are stored for subsequent
processing usually in combination with a master file.
Transaction data may be collected automatically or may initially be recorded on source documents
and later converted to a machine readable format. This leads to the creation on transaction records
that are stored in transaction file.
A transaction file contains the records that are used to update the records of the master file. It is very
important that the transaction file should contain records with the fields and their names in the same
order and size and type as that of the master file.

2.1.3 Sequential, Relative and Indexed File

Sequential file: Sequential file is one in which the records are stored some sequence or order.
For example: A student’s file may be kept in the order of ascending roll number.
Advantages of Sequential File Organization:

a. File design is simple.

b.Location of records requires only the key record .

c.When the activity rate is high, simplicity of the accessing method makes processing efficient.

d.Low-cost file medium such as tapes can be used.

Drawbacks of Sequential File Organization

a. Updating requires that all transaction records to be first sorted in the key record sequence.
b.A new master file, physically separate and exclusive is always created as a result of sequential
updating.

c.Information on the file is not always current. Addition and deletion on records are not simple tasks

Relative file: Relative files are other types of disk files that also permit random access. Relative file
does not use an index to access records randomly. Rather the key field of each record is used to
calculate the record’s relative location in the file stored on the disk.. With the relative files the key
field is converted to an actual address.

Index file: An indexed file is one that has an index for looking up locations of records on a disk. This
index enables the user to access a disk file randomly.Index files are very useful for processing where
a user communicates directly with the computer using a key field he or she is entering( not
necessarily enter in sequence).Once the address of the disk record is obtained from an index the
access mechanism can move directly to that address on the disk where that record is located. Hence
the method of accessing record will be faster.

2.1.4 Modes of Processing

There are several methods of processing data depending on the type of data and the time available for
the processing and getting results:

a. Batch processing: Batch processing is one of the oldest methods of running programs that is still
being employed by many data processing centres for processing their jobs.

It is based on the idea of automatic job-to-job transition facility prepared by almost al operating
systems.
Batch processing is also known as serial, sequential, off line or stacked job processing.

b. On-line processing: Online processing permits transaction data to be fed directly into secondary
on-line storage devices.

Here the access to, retrieval of, any record is quick and direct.
Online processing systems feature random and rapid input of transactions and immediate and direct
access record contents as and when needed.

c. Real-time processing: Real time means immediate response from the computer. A system in
which a transaction accesses and updates a file quickly enough to affect the original decision making
is called a real-time system.

Here files are updated each minute, and enquiries are answered by split-second access to up-to-the-
minute records.

Questions:
Q1. Explain types of files.
Q2. Explain modes of processing.
CHAPTER 3: PRINCIPLES AND TECHNIQUES OF
PROGRAMMING

3.1 Introduction to Programming


Programming is the art and science of creating computer programs. Programming begins with
knowledge of one or more programming languages such as C,C++,C#.
Programming requires a similarly logical approach to designing, writing, testing and debugging a
program.

Program Life Cycle


Every computer based system just as living organism has a life cycle. Commercial program such as
Payroll, Inventory control and other software share a common life cycle pattern. To keep up with
new technology, a program may become inadequate to meet future needs. At this point of time,
investigations are made, requirements are analyzed and new specifications are proposed and a new
system is developed. The life cycle of new system thus starts again. Once a new system is
operational, the development team is dispersed. But one last task should be completed before person
involve in the project are assigned to other activities-review of the system .A report might review the
need for recycling and listing reasons for schedule and budget slippage and outline liaison and
communication problem that occurred during development. Mistakes should be identified and an
analysis made of reasons for the mistake and how they could have been avoided. Such a document
will help future development teams avoid similar pitfalls and lead to improved development
procedures

3.2 Program Definition


Program: A program is a collection of instructions that control the computer what to do. A program
is called software, hence, program, software and instructions are synonymous.
A program is made up of :

 Instructions: Instructions are the directions that the computer will follow and a particular
sequence of instructions is called the program‟s logic.

 Buffers: Buffers are reserved spaces in the computer memory that will accept and hold the data
while it is being processed.

 Constants: Constants are fixed values within the program that are used for comparing.

3.3 Characteristics of Good Program


Programming style should have the following three important qualities:
a. Readability: The source code or the program should be written in high level language so that it is
readable to you and others.

b. Portability: Write the code using high level language so that it is easy to transfer the program to
other machines as well.

If possible, avoid non-standard features an also use the standard library runtime routines rather than
writing your own and thus save time.

c. Maintainability: While writing the program think about how you might want to change or extend
it in future.

For example, put data structure definitions in header files where changes will automatically broadcast
to all source files that include the header file.
Guidelines for Good Programming:

1. Use a few standard control structures.

2. Use goto in a disciplined manner.

3. Hide data structure b behind access function.

4. Avoid null statements

5. Use parenthesis, backspaces when needed.

6. Do not use an identifier for multiple purpose.

7. Nesting of program constructs should nor exceed five levels.

8. Provide standard documentation.

3.4 File Handling


File handling refers to several levels of managing data. They are:

a) File handling is the part of the operating system that manages the physical storage and retrieval of
data on a floppy disk or other storage device.

b) File handling refers to the software that allows for the creation, storage, retrieval and manipulation
of files interactively at a terminal or personal computer.

c) File handling is the management of all files or data and information within an organization and
includes data administration, the standards for defining data and the way in which people perceive
and use it in their day-to- day tasks.
d) File handling is a function within an organization that manages the file.

3.5 Introduction to Flowchart


Flowchart: A flowchart is a graphical representation of the sequence of operations in an information
system or program. Program flowchart shows the sequence of instructions in a single program or
subroutine.
Flowchart uses boxes of different shapes to denote different types of instructions.

3.5.1 Flowchart Symbols

The American National Standards Institute (ANSI) has standardized flowchart symbols
The symbols are:

1. Processing: A processing symbol is used in flowchart to represent arithmetic and data movement
instructions. Rectangle

2. Flow lines: Flow lines with arrowheads are used to indicate the flow of operation, that is, the exact
sequence in which the instructions are to be executed. Straight and horizontal Lines

3. Decision: The decision symbol is used in a flowchart to indicate a point at which a decision has to
be made and a branch to one of two or more alternative points is possible. Diamond

4. Connector: Whenever a flowchart becomes too complex that the number and direction of flow
lines is confusing or it spreads over more than one page, it is useful to utilize the connector symbol as
a substitute for flow lines. This symbol represents an entry from, or an exit to another part of the
flowchart. Small circle

5. Terminal - rectangle like with two rounded sides

6. Input/Output - rhombus

3.5.2 Advantages of Flowcharts

 Conveys meaning better

 Analyzes the problem effectively

 Effective joining the Parts of a system

 Efficient Coding

 Systematic Debugging

 Systematic Testing
3.5.3 Limitations of Flow charts

 Takes more time to draw.

 Difficult to Make Changes.

 Non- Standardization

3.6 Psuedocode
Pseudocode is program analysis tool that is used for planning program logic. It is an imitation of
actual computer instructions and these are written in ordinary natural language such as English.
Examples of Pseudocode:

Example 1: Working with Masala Dosa Mincer

Pseudocode:
BEGIN
Turn Mincer On
Mince Dosa Masala
Turn Mincer Off
END

Operation on File:

The following are the basic operations performed on files:

1)Inputting or Writing to a file.


2)Outputting from a file or Reading afile
3)I/O and Deleting a file:

3.7 Programming Paradigms

3.7.1 Procedural programming

Procedural programming is based on the procedures. In the procedural programming, all the
returning sequences if statements placed in main program. A procedure call is used to invoke the
procedure. After the execution of statements, flow of control return after the position where the call
was made.

3.7.2 Modular Programming


Modular Programming is the splitting up of the programs/problems into series of self contained
modules. A module should not exceed about 100 or so lines and should preferably be short enough to
fit on single page.

3.7.3 Structured Approach to Programming


Structured programming can be seen as a subset or sub discipline of imperative programming, one
of the major programming paradigms. It is most famous for removing or reducing reliance on the
GOTO statement.

3.8 Top-Down Approach

Top-Down Design is the technique of breaking problem down into the major tasks to be performed.
Each of these tasks is the further broken down into separate subtasks, and so on till each subtask is
sufficiently simple to be written as a self contained module or procedure. The program then consists
of a series of simple modules.

3.9 Bottom-Up Approach


When faced with a large and complex problem, it may be difficult to see how the whole thing can be
done. It ma be easier to attack parts of the problem individually, taking the easier aspects first and
thereby gaining the insight and experience to tackle the more difficult tasks, and finally to try bolt
them all together to form the complete solution. This is called a Bottom-Up Approach.

Questions:
Q1. What are the characteristics of good programming?
Q2. What is a flow chart? Explain its symbols?
Q3. What is Pseudocode?
Q4. Explain types of Programming.

Potrebbero piacerti anche