Introduction to Programming, Algorithms and Flowcharts
9
The PC, or program counter, is a CPU register that
holds the address of the next instruction to be executed
in a program. In the beginning, the PC holds the address
of the zeroth instruction of the program. The CPU fetches
and then executes the instruction found at this address.
The PC is meanwhile incremented to the address of the
next instruction in the program. Having executed one
instruction, the CPU goes back to look up the PC where
it fi nds the address of the next instruction in the program.
This instruction may not necessarily be in the next
memory location. It could be at quite a different address.
For example, the last statement could have been a go to
statement, which unconditionally transfers control to a
different point in the program; or there may have been a
branch to a function subprogram. The CPU fetches the
contents of the words addressed by the PC in the same
amount of time, whatever their physical locations. The
CPU has random access capability to any and all words
of the memory, no matter what their addresses. Program
execution proceeds in this way until the CPU has processed
the last instruction.
Points to Note
1. When a program is compiled and linked, each instruction
and each item of data is assigned an address.
2. During program execution, the CPU fi nds instructions
and data from the assigned addresses.
1.5 FOURTH GENERATION LANGUAGES
The Fourth Generation Language is a non-procedural
language that allows the user to simply specify what the
output should be without describing how data should
be processed to produce the result. Fourth generation
programming languages are not as clearly defi ned as are
the other earlier generation languages. Most people feel
that a fourth generation language, commonly referred to
as 4GL, is a high-level language that requires signifi cantly
fewer instructions to accomplish a particular task than
does a third generation language. Thus, a programmer
should be able to write a program faster in 4GL than in a
third generation language.
Most third generation languages are procedural
languages. That is, the programmer must specify the steps
of the procedure the computer has to follow in a program.
By contrast, most fourth generation languages are non-
procedural languages. The programmer does not have
to give the details of the procedure in the program, but
specify, instead, what is wanted. For example, assume
that a programmer needs to display some data on the
screen, such as the address of a particular employee, say
MANAS, from the EMP fi le. In a procedural language, the
programmer would have to write a series of instructions
using the following steps:
Step 1: Get a record from the EMP fi le.
Step 2: If this is the record for MANAS, display the
address.
Step 3: If this is not the record for MANAS, go to
step 1, until end-of-fi le.
In a non-procedural language (4GL), however, the
programmer would write a single instruction that says:
Get the address of MANAS from EMP fi le.
Major fourth generation languages are used to get
information from fi les and databases, as in the previous
example, and to display or print the information. These
fourth generation languages contain a query language,
which is used to answer queries or questions with data
from a database. The following example shows a query in
a common query language, SQL.
SELECT ADDRESS FROM EMP WHERE NAME =
‘MANAS’
End user-oriented 4GLs are designed for applications
that process low data volumes. These 4GLs run on
mainframe computers and may be employed either by
information users or by the programmers. This type of 4GL
may have its own internal database management software
that in turn interacts with the organization’s DBMS
package. People who are not professional programmers
use these products to query databases, develop their
own custom-made applications, and generate their own
reports with minimum amount of training. For example,
ORACLE offers a number of tools suitable for the end
user.
Some fourth generation languages are used to produce
complex printed reports. These languages contain certain
types of programs called generators. With a report generator,
the programmer specifi es the headings, detailed data,
and totals needed in a report. Thus, the report generator
produces the required report using data from a fi le. Other
fourth generation languages are used to design screens
for data input and output and for menus. These languages