0% found this document useful (0 votes)
4 views

Intro to Programme Hand Out 2

The document outlines the fundamentals of computer programming, including the definition of a computer program, types of programming (system and application), and the basic principles of programming. It details the stages involved in program development, such as problem definition, solution design, coding, testing, and documentation. Additionally, it introduces computer programming languages, their classifications, and the translation methods used to convert high-level languages into machine-executable form.

Uploaded by

taiwoalawiye0
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Intro to Programme Hand Out 2

The document outlines the fundamentals of computer programming, including the definition of a computer program, types of programming (system and application), and the basic principles of programming. It details the stages involved in program development, such as problem definition, solution design, coding, testing, and documentation. Additionally, it introduces computer programming languages, their classifications, and the translation methods used to convert high-level languages into machine-executable form.

Uploaded by

taiwoalawiye0
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

TABLE OF CONTENTS

Unit 1 The Art of Computer Programming

Unit 2 Computer Programming Languages

Unit 3 Introductory Theory of Algorithms

Unit 4 Flowcharting Techniques

Unit 5 Structured Programming

Unit 6 Intro to Programming Languages

Unit 7 Intro to basic programming

Page | 1
UNIT 1
THE ART OF COMPUTER PROGRAMMING

INTRODUCTION

In this unit you are going to be introduced to the principles of computer programming. As you know,
a Computer is not a useful device as an entity (anything about which information or data can be
stored in a database) without a programming force driving its operations. Generally, a complete
computer system is made up of the following:

• Hardware

• Operating System Software

• Application Software

In fact, a better way of illustrating the above is as follows:

1.1 DEFINITION OF A COMPUTER PROGRAM

A PROGRAM is a series of step-by-step instructions that provides a solution to a particular problem


and directs the computer on what to do exactly or a software application designed to perform a
specific task. Now, though a program is a set of instructions, but the statements must be submitted
to a computer as a unit to direct the computer behaviour. There are generally two major types of
programming:

System Programming

Application Programming

SYSTEM PROGRAMMING

In short, system programs constitute the driving force behind the operations of the Computer
System. They are specially designed to facilitate the use of the hardware and to make the Computer
System function efficiently and run quickly.

Page | 2
During the early days of Computer Systems, human operators monitored computer operations,
decided on the order in which submitted programs should be run and made ready through the input
and output (I/O) devices. Even though the speeds of Central Processing Units (CPUs) increased as a
result of early electronic revolution, the speed of human operators behind the operational
procedures of the computer did not increase. There were therefore time delays and errors by the
human operators which constituted most of the problems that led to the development of a Super-
Controller program that handle the problems caused by human-operators. This special program is
what we call an OPERATING SYSTEM (OS).

Operating System

An Operating System is a collection of system programs that jointly controls the operations of a
computer system and its resources. An OS simply helps you to efficiently and reliably run other
programs and manage your files. Now, with an OS installed on your computer system, most of the
responsibilities of human operators that characterized early generation computer operations, such
as preparing the I/O device to be used for each program or loading the programs into memory, are
now all done by the operating system.

But before concluding on the brief review of OS, the following are some common examples of
operating systems:

• Disk Operating System (DOS) — Microsoft original OS.

• Microsoft Windows Operating Systems (Windows 95, 98, 2000)

• Microsoft Windows NT

• Microsoft Windows XP

• Unix

• Linux

• Novel Netware

The above are found on most Personal Computers (PCs). However, we equally have the:

• Macintosh Operating System - this runs only on the Apple Macintosh machines.

• Palm OS — which runs on handheld computers, PC Phones or Palmtops.

• Windows CE — a slimmed version of Windows that runs on handheld PCs.

• Symbian OS that runs on PDAs or Mobile phones like Nokia 9300/9500

There are two types of programs that make up the Operating System:-

➢ Control Programs

➢ Processing Programs
Page | 3
Control Programs: The OS control programs generally oversee the system operations and carry
out tasks such as Input/output (I/O), scheduling, communicating with the Computer user or
programmer and handling interrupts. An interrupt is just a signal sent to the CPU indicating that an
event has occurred.

Processing Programs

The OS processing programs are those that facilitate efficient processing operations by simplifying
program preparation and execution for you as a user. The major processing programs existing in the
OS are as follows:

• Language Translators

• Linkage Editor

• Library Programs

• Utility Programs

APPLICATION PROGRAMMING

Application Programs are those that perform specific computational tasks or data processing to
solve user's problems. From this definition, you can see that application programs concentrate on
the particular problems to be solved.

Broad categories of application programs are stated below:

• Word Processing Software

• Database Applications

• Electronic Spreadsheet applications

• Desktop Publishing applications

• Web Publishing Software

• Communication Software

• Accounting Software

• Graphic Tools

• Design Software (e.g. CAD Packages)

• Modelling Software

• Video Editing ... and others

Page | 4
1.2 BASIC PRINCIPLES OF PROGRAMMING

As you have already seen in the last section, a computer program is designed to solve a specific
problem following the execution of the program instructions. However, you should know that a
Computer does not solve problems the way we do. Human beings make use of reasoning,
intelligence and intuition to solve problems while computers solve problems according to
instructions supplied by programmers.

In view of the above, every program has to be properly designed so as to solve the problem behind
its development effectively and accurately. Before you are introduced to the basic steps involved in
program development, you should know the aims guiding the design of a good computer program.
These are as follows:

• Reliability

• Maintainability

• Portability

• Readability

• Performance

• Memory Saving

Let us see these one by one.

Reliability: By reliability, we mean that you should be able to depend on the program to always do
what it has been designed to do.

Maintainability: By this, we mean that you should be able to modify the program when the need
arises.

Portability: The concept of portability in programming is that a program should be capable of being
transferable to different computer platforms with a minimum modification, if any at all.

Readability: A program should be easy for other programmers to read and understand. For example,
a readable program is easier to maintain.

Performance: A program that doesn’t carry out the expected tasks quickly and efficiently has lost
the performance aim. Therefore, a major aim in program design is that the program should execute
quickly and efficiently too.

Memory Saving: What is meant here is simply that a program should not be unnecessarily too long
and requiring excessive large memory to execute.

Page | 5
Having gone through the aims underlying the designs of programs, you will now see below the
different stages involved in program development:

• Problem Definition

• Solution Design

• Program Coding or Writing

• Program Testing

• Program Documentation and Maintenance

The above will be explained further as follows:

PROBLEM DEFINITION: Problem formulation or definition is very essential in programming and it


begins with recognition of a need for information by a user or an organisation. The programmer is
expected to analyse the problem thoroughly in order to understand what is required of its solution.

Generally, if you describe a problem carefully at the beginning of the programming process, your
program will be better and might cost less to develop.

One way of defining a problem is to do that in terms of the following:

• Input

• Output

• Processing

Starting with OUTPUT, this represents the information requirements of users of the program. This
is the reason most of the times the programmer can simply use a report generated by a program to
design the corresponding input form or interface.

Having determined the output requirements, then the INPUT required providing the output should
be determined too. Finally, based on the input and output requirements, the PROCESSING can then
be determined.

SOLUTION DESIGN: What is best to do here is for the programmer to take each step or segment of
the problem definition and then work out a tentative program flow. When you approach the
solution by handling each segment separately, you can concentrate on developing an efficient and
logical flow for that segment. This is the approach employed in what is called "Modular
Programming", where a program is divided into parts or modules for easy development and
maintenance

PROGRAM CODING OR WRITING: Next to the two steps of program development described
above is the coding or writing of the program itself in a specific programming language, especially
High Level Languages (HLL), such as Basic, Pascal or C++, which you will be introduced to in the next
unit.
Page | 6
Generally, the definition and solution of a problem do not depend on a particular programming
language. But most of the times, the proposed solution may limit the choices of languages that can
be employed. It is also necessary to know that some language' are better suited for some types of
problems as you will see in the next unit.

PROGRAM TESTING: After the coding or writing of a program, it is submitted to the computer for
testing. Generally, testing involves the following:

• Debugging

• Compiling

• Testing (in stages)

Debugging: Errors in programs are usually called bugs and the processing of removing errors in your
programs is called debugging.

Compiling: Your program has to be translated before the computer can execute it. Compiling is one
way of translating your program into machine language

Testing: Usually, for a large program that has been developed using modular method, there are
various stages of testing as follows

• Unit Testing

• Integration Testing

• System Testing

• User Testing

Unit testing: Involves testing the separate components or modules as they are being developed.

Integration Testing: involves testing the program as separate modules are put together. Finally, on
the part of the programmer,

System Testing: occurs when the whole program is being tested in its final form to be ready for use.
However,

Users testing: This is when the user of the program tests the final program to see whether it meets
his or her needs.

PROGRAM DOCUMENTATION AND MAINTENANCE

There is no good programming without documentation. This is the documentation of all the work
involved in the program development. The documentation should consist of all written descriptions
and explanations of the program and other materials associated with the development.

Generally, proper documentation serves as a reference guide for programmers and system analysts
who are to modify the programs and their procedures when the needs arise.

Page | 7
CONCLUSION

In this unit, you have been introduced to the two main types of programming, namely, System
programming and Application Programming. As you have learned in the unit, system programming
facilitates the use of the Computer hardware and the running of the application programs. The
application programs are simply those that solve the users' problems. The unit has equally taken you
through the basic stages involved in programming.

SUMMARY

This unit has shown you that the computer machine is simply an electronic device which only
becomes a useful tool through its programming. According to what you have learned in the unit,
every computer program is designed to solve a specific problem or perform a particular task. Hence
the art of programming starts by defining your problem and then followed by the designing of the
solution. A very vital aspect of programming from what you have learned in this unit is the
documentation of your program and this should be an ongoing process for a program that is
regularly modified to keep pace with the changing needs of its user.

Page | 8
UNIT 2
COMPUTER PROGRAMMING LANGUAGES
INTRODUCTION

Historically, instructions for Computer processing in the early days of the Computer had to be either
wired on control panels and plugged into the machine at the start of a job processing or had to be
read from punched cards in distinct steps of the job processing. Any of these methods was very slow
since the computer had to wait for these instructions to be fed in by a human operator.

To speed up processing, the computer memory became useful to store instructions as well as data.
This development introduced what was known as Stored-Program concept. The need to represent
instructions in one form of code or the other gave birth to the notion of Programming Language and
the first form of these codes became what is called the Machine Language (ML).

2.1 CLASSIFICATION OF LANGUAGES

There are various ways of categorising computer programming languages. One way of doing this is
to classify them by the following:

• Level

• Purpose

• Orientation

• Structure

• Translation Method

LEVEL CLASSIFICATION

Under this classification we have:

• Machine language

• Low-Level/Assembly Language

• High-Level Language

• Very High level Language

Machine Language: Machine Language is generally called the lowest- level language and it was the
first language available to computer programmers. It is very fast since the language needs no
translation because its instructions are made up of zeros and ones (0's and 1’s). Thus Machine
Language is merely data to the computer and the program can modify itself during execution.

The advantages of Machine Language (ML) can be summarised as follows:

Page | 9
• Fast execution speed

• Storage Saving

• Programmer's full control of the Computer and its capabilities

However, ML has some disadvantages as follows:

• Difficult to learn

• Highly prone to errors

• Totally machine-dependent — this means that programs written in ML will only execute on the
specific machine they were written.

You have been informed that ML is the lowest-level language. Hence it is the most efficient language
and it is good for you to know that every computer responds only to its machine language.

Assembly Language: The next in the hierarchy of languages that is closer to the Machine Language is
the Assembly Language (AL). Assembly Language was developed in the early 1950s to alleviate some
of the difficulties associated with the Machine Language. Symbolic names or mnemonics were used
to replace the binary code of the Machine Language.

Remember that a mnemonic means a memory aid ( the textual human-readable form of an assembly
language instruction). Hence AL instructions are easier to remember than the 0's and 1's of the ML
instructions.

Below are the Advantages of the AL:

• It is efficient in processing time and in the use of memory space.

• It encourages Modular Programming, where programs are broken into modules.

• It provides an error listing which is useful in debugging.

• Since it is very close to machine language, it is also fast.

Disadvantages of Assembly Language

• It is cumbersome in usage.

• Assembly Language has one-to-one-relationship with machine language, meaning that one
Assembly Language instruction is translated into one Machine Language instruction. This process
leads to long program preparation time.

• Assembly Language is machine-dependent like the Machine Language.

High Level Languages: High-Level Languages (HLL's) are machine- independent and they are
either

• Procedure-Oriented, or

• Problem-oriented
Page | 10
These are treated under orientation classification.

Very High level Language: Very High Level Languages (VHLL's) or what are usually referred to as the
4th Generation Languages (4GL's). Below are the basic characteristic layers of a simple 4GL:

• Database

• Data Communication

• Data Processing

• End User Facilities (EUF)

A language such as Visual Basic which equally has database capabilities can be classified as a 4GL.

PURPOSE CLASSIFICATION
Under this classification, you have:
• General-Purpose Languages
• Special-Purpose Languages

A general-purpose language is one that can be used to solve a variety of problem types. From what
you have learnt already about low- level language, it means that the lower the level, the more
general purpose the language.

A special-purpose language is one that can be used for specific types of problems, such as a
language called WPL (Word Processing Language) developed by Apple for word processing.

ORIENTATION CLASSIFICATION

In this classification, you have the following:

• Procedure — Oriented Languages

• Problem — Oriented Languages

In using a procedure-oriented language, you have to specify how to solve a problem by indicating
the procedures the computer will follow step by step.

In a problem-oriented language, you simply specify what to obtain as your results while the
development of the procedures is left to the language.

TRANSLATION METHOD CLASSIFICATION

Among all the Computer programming languages, only the machine language is in machine-
executable form. All other languages must be translated into O's and l's, the only things understood
by the computer.

Page | 11
Now, translators take the forms of the following:
• Interpreter
• Compiler
• Assembler

Interpreter: Some languages are interpreted by converting the "source program" into machine
language as the program is being executed. Interpreters translate code line-by- line which therefore
makes them run slowly than other translators. For example, sonic BASIC language versions only
interpret programs instead of compiling them. However in Turbo Basic, KBASIC or BASIC 4GL you can
compile the BASIC source code into an executable code.

Compiler: Unlike an Interpreter, a Compiler translates an entire program into machine language
before the execution of the program. A Compiler usually translates the SOURCE program into
another program called the OBJECT program which is the machine language version of the source
code. With the object program created by your compiler, you will never use the source program
again except when you want to modify it. Generally, a compiled program runs faster than an
interpreted program.

Assembler: You have already been introduced to the Assembly Language which is neither compiled
nor interpreted. For the language, it is simply assembled. Since the assembly language is already
close to the machine language, assembling a program is therefore less time-consuming than
compilation.

High-Level Languages can further be classified again as follows, remembering that there are many
ways of classifying computer programming languages:
• Scientific-Oriented Languages
• Business-Oriented Languages
• Multi-Purpose Languages
• Education-Oriented languages
• Natural Languages

CONCLUSION
In this unit, you have been introduced to the general classification of computer programming
languages, namely, low- level and high-level languages. The two low-level languages are the machine
language and the assembly language, the former being the lowest. The machine language, as you
have learnt in this unit is the only language understood by the Computer and all other languages
have to be translated into the language for the Computer to execute their instructions.

SUMMARY
This unit has presented to you an overview of computer programming languages. Apart from the
low- level languages, namely, the machine and assembly languages, you were introduced to some
common examples of high-level languages The basic characteristics of some of these languages such
as BASIC, FORTRAN, PASCAL, C++ and HTML will be treated later in this course.

Page | 12
UNIT 3
INTRODUCTORY THEORY OF ALGORITHMS

INTRODUCTION

As you already learnt in unit 1 that a computer program is usually designed to solve a specific
problem. However, a PROGRAM belongs to a larger class of problem-solving techniques known as
ALGORITHMS. This unit is therefore aimed at introducing you to the basic theory of problem-solving
and its relationship with algorithms.

3.1 PROBLEM THEORY AND ALGORITHMS

The design and development of algorithms rest solely on the principles of problem theory. You may
ask, what is an algorithm? Precisely, an algorithm is a procedure for solving a particular problem.
Every problem is usually characterized by the following states:

• Initial State

• Goal State.

Every algorithm is designed to transform a problem from its Initial (or unsolved) state to its Goal (or
solved) state by means of permissible operators or steps specified by the algorithm.

3.2 ALGORITHM CRITERIA

Every algorithm is expected to satisfy the following criteria:

• Input Criterion

• Output Criterion

• Precision Criterion

• Finiteness Criterion

• Efficiency or Effectiveness Criterion.

Input Criterion: There should be zero or more values which are externally supplied to the algorithm.

Output Criterion: An algorithm should provide an output of implementation or experimentation.


This is very essential to check the correctness of the algorithm.

Precision Criterion: Each step of an algorithm must be clear without any ambiguity or any inherent
assumptions.

Finiteness Criterion: An algorithm must terminate after a finite number of steps. There should also
be a stopping criterion to terminate an algorithm in a case of a step with repeated execution.

Efficiency Criterion: Each step of an algorithm must be sufficiently basic that it can be carried out in
principle. That is, each step must be feasible (in addition to being definite or precise). There must

Page | 13
never be an impossible task included in algorithm steps. In actual programming, an example of
impossible tasks is when a quantity is being divided by zero.

3.3 ALGORITHM REPRESENTATION

Below are the common forms of representing algorithms:

• Pseudo code

• Flowcharts

• Decision Table

PSEUDOCODE

A Pseudo code is a logical representation of an algorithm using third generation language (3 GL) style
such as DO, WHILE, IF-THEN-ELSE, etc. Pseudo code is also called structured English since it is
English- like in structure. It is essential to know that a Pseudo code is not directly executable on a
computer except it is transformed into a high- level language code.

Interestingly, Pascal language has a general form for its Pseudo code which cannot be said of other
languages. The general form is as follows: ALGORITHM name DECLARE definitions and declarations
EXECUTE statements to be executed END name. As you can sec above, a Pascal Pseudo code is
simply made up of four blocks:
• Algorithm Name
• Declarations
• Executable Statements
• End of algorithm. See an example below.

Example 1: Algorithm that finds the average of two numbers-

ALGORITHM average
DECLARE
a, b, c: REAL
EXECUTE
INPUT a, b
c = (a+ b)/2
OUTPUT c
END average.

Instruction Execution: The instructions in an algorithm are usually executed one after the other as
they appear in the algorithm steps.

Algorithm Completion: Generally, an algorithm is completed with the execution of the last
instruction. However, an algorithm can be terminated at any intermediate state by using the exit
instruction.

Page | 14
Example 2: Algorithm that can terminate before the end of instruction-

ALGORITHM comparison
DECLARE
a, b, c : INTEGER
EXECUTE
INPUT a, b, c
IF (a > b) & (b > c) THEN
OUTPUT “a is the Greatest”
EXIT
ELSE IF (a < b) & (b > c) THEN
OUTPUT “b is the Greatest”
EXIT
ELSE
OUTPUT “c is the Greatest”
END comparison.

CONCLUSION

In this unit, you have learnt the basic concepts of problem theory and how they are related to
algorithm development. The unit has also shown you the essential criteria that characterize ever
algorithm. If you remember, they are: • Input • Output • Precision • Finiteness • Efficiency. Finally,
in this unit, you have been introduced to some various forms of representing algorithms.

SUMMARY

Problem theory is very fundamental to the design and development of algorithms as you have been
taught in this unit. The unit has therefore taken you through some basic concepts of problem theory.
This unit has also specifically shown you the major characteristics of algorithms and how they are
represented in various forms. The next unit will specifically take you through a very essential and
common way of representing algorithms which is very basic to computer programming design.

Page | 15
UNIT 4
FLOWCHARTING TECHNIQUES CONTENTS

INTRODUCTION

The task of computer programming rests to a large extent on the ability of the computer
programmer to properly make use of the initial analysis and design tools available to him.
Programming is one of the essential components of the broad task of system analysis and design.
For analysis and design work to be useful, it must be expressed in one understandable form or the
other. In general practice, analysts and programmers make use of diagrams and charts as important
tools. In this unit, you will therefore be introduced to the use of flowcharts, specifically in
programming.

4.1 TYPES OF FLOWCHARTS AND SYMBOLS

Under the broad area of System Analysis and Design of which programming is a component, you can
classify diagrams and charts used by analysts and programmers as follows:

• Data Flow Diagrams (DFD): illustrates how data is processed by a system in terms of inputs and
outputs. As its name indicates its focus is on the flow of information, where data comes from, where
it goes and how it gets stored.

• System Flowcharts: showing controls at a physical or resource level

• Forms Flowcharts: Forms Flowcharts are simply employed to supply this information of how
documents and forms flow among the organizational units. They don't indicate how data are
processed.

• Program Flowcharts: showing the controls in a program within a system

Usually, the flowchart symbols are arranged in the same logical sequence in which corresponding
program statements will appear in the program.

As a programmer, you are expected to be very familiar with how to construct a good program
flowchart. This is because flowcharts provide excellent way of documenting your program.
Moreover, flowcharts serve as good maintenance tools since they can be employed to guide the
programmer to determine what statements are required to make any necessary modifications and
where to locate them.

4.2 FLOWCHART SYMBOLS

Flowcharts generally make use of symbols that are assigned specific meanings. The common symbols
are as follows, in the table below:

Page | 16
Program flowcharts can be divided into two:
• Macro Flowchart

• Micro Flowchart.

A macro flowchart is the flowchart that outlines the general flow and major segments of a program.
It is also called the "Modular program flowchart" where the major segments of the program are
called the modules. Specifically, macro flowcharts are those called Block diagrams as earlier
mentioned.

Unlike macro flowcharts, a micro flowchart shows the logic of the program in full detail. Hence it is
also called a "Detail Flowchart". Micro flowcharts usually depict the processing steps required within
a particular program and often consist of a one-to-one correspondence between flowchart blocks
and program statements.

3.2 Applications of Flowcharts

In this section, you will be introduced to some simple examples of problems with their associated
flowcharts. You will start with the example in unit 3, having the following Pseudo code.

Having the following Pseudo code:

Start
read: a, b
set c = (a + b)/2
if c <0 then

Page | 17
write: "Average is negative"
re-start
else
end if write: c
End.
However, remember you used Pascal Pseudo code for the above example in unit 3. Before drawing
the simple flowchart for the problem, modify the Pseudo code as follows:

Start
read: a, b
set c = (a + b)/2
if c <0 then
write: "Average is negative"
re-start
else
end if write: c
End.
The flowchart for the above problem is as follows:

The above flowchart uses the most commonly used symbols, namely:

•Terminals
• Input/output
• Processing
• Decision.

Page | 18
Example 2

START
DOWHILE staff number ? 0
READ: staff weekly work record
IF work is hourly THEN
CALCULATE gross pay
ELSE
Pay = (annual salary)/52
ENDIF
Update payroll file
ENDDO
END.
In the above Pseudo code, the calculation of the gross pay is taken to be a pre-defined process. The
flowchart is as follows in an unbroken form:

Page | 19
UNIT 5
STRUCTURED PROGRAMMING CONTENTS

INTRODUCTION

This unit is aimed at introducing you to the basic elements of structured programming with their
appropriate illustrative flowcharts. Now, look at your study objectives for this unit.

They are as follows:

• Sequence Structure

• Selection Structure

• Iterative Structure.

SEQUENCE STRUCTURE

In sequential structure or what you can also call sequential logic, the steps are executed one after
another as serial operations. This can be illustrated by the following flowchart:

Looking at the above flowchart, there are two arrows one at the top leading to the first process box
and one at the bottom leading out from the last process box. They respectively represent the entry
at EXIT points of the program segment. It is good to state here at a basic guideline of structured
programming is that each module should have only one entry point and one exit point. For this
reason, a program that has only one entry and one exit is called a proper program.

SELECTION STRUCTURE

The selection structure uses conditions and based on the decision taken by the computer after
comparison of data, one of the available alternatives is selected. For this reason, it is also called
alternation structure or Conditional structure. You can also call it the if structure.

The selection structures can be categorized as follows:

• Single Alternation

• Double Alternation

Page | 20
• Multiple Alternation.

Single Alternation

This is described by the following flowchart:

In the above flowchart, if the condition is satisfied, then the instruction(s) in the Process box (or
what is also called ACTION BLOCK) is/are executed. If the condition is not satisfied, the control
transfers to the next instruction follow condition.

The Pseudo code is as follows:

IF condition THEN

Action-block statement(s)

ENDIF

Double Alternation

The structure is illustrated below:

The Pseudocode for the above structure.

Page | 21
IF condition THEN

Action — block - 1

ELSE

Action block — 2

ENDIF

Multiple Alternations

The structure is seen in the following flowchart using three conditions

Looking at the above flowchart, you will see that if none of the four conditions is satisfied, then the
process in the ELSE box will be executed.

Iterative Structure

Iterative Structure is of the following two forms generally


Page | 22
• WHILE Loop
• DO-UNTIL Loop.
WHILE Loop

To start with, an iterative structure is also called the Loop or Repetition structure. Now the WHILE
loop which you can also call the DO-WHILE structure is illustrated below:

A pseudo code for the above flowchart is as follows:

WHILE condition DO

statement(s)

ENDWHILE.

When using the WHILE loop, the following points are essential:

• Have an instruction that initializes the condition before the use of the WHILE structure.

• Let there be an instruction that modified the condition within the loop. Without such a statement,
the loop will repeat itself indefinitely.

As you have seen in the

-above flowchart, the "condition" is used to control the loop. Thus the loop is executed until the
condition no longer remains true.

Page | 23
You can also call the above structure the REPEAT –UNTIL structure. A Pseudo code for this logical
structure is therefore as follows:

REPEAT
Statement(s) UNTIL
Condition

For Loop

This is illustrated below, using the following flowchart:

A Pseudo code for the above type of loop is as follows:

FOR I = j TO by s DO
Statement(s)
ENDFOR.

Page | 24
In the above Pseudocode, the variables are defined as follows:

i = index variable

J = initial value

k = final value

s = step size.

Essentially, the index variable i controls the loop while the step size can either be negative (to
implement decrement) or positive (to implement increment). When the step size is not stated, the
default step size is taken to be 1.

STRUCTURED PROGRAMMING METHODS

In this section, you will be introduced to the two methods employed in developing a structured
program. The two methods are:

• Level programming

• Path programming.

Level Programming

Programming by level is also called Top-down programming technique and it is characterized by


writing all the program modules on level one or top-most level before programming the modules on
level two. In the same vein, the modules on level two are programmed before the modules on level
three, and so on.

An illustration is as follows:

Page | 25
Path Programming

This is a method where all modules along a logical path in the program are developed in sequence.
See the illustration below:

The Path Programming is also called Backtracking programming. The method helps the programmer
to backtrack to the first unwritten module that is directly connected to the path being developed,
until all modules are developed.

Page | 26
UNIT 6
INTRO TO PROGRAMMING LANGUAGES

INTRODUCTION

It is good for you to know that a language can have any of the above characteristics with one of the
two earlier features, that is, problem-oriented or procedure-oriented feature. This should not
confuse you.

Now, it is time to introduce you to some common high- level languages.

FORTRAN

You are starting with Fortran because it is generally referred to as the first high- level language. The
name is the short for "FORmula TRANslator. Fortran is a scientific-oriented and problem-oriented
language. Since early computer users were scientists and engineers, it was not therefore surprising
that the first high- level language was designed to solve scientific problems. The language was
developed by an IBM (International Business Machines) group led by John Backus in 1957, though its
first appearance was in 1956 according to some authors. There have been various versions of the
language as follows:

• Fortran II in 1959

• Fortran IV in 1966

• Fortran 77 in 1977

• Fortran 90/95 — the latest version.

BASIC

BASIC is the acronym for "Beginner's All-purpose Symbolic Instruction Code" and it is the most
popular programming language. It is an Education-oriented language developed in 1965 for use by
Colleges and Universities for instructional purposes. It is also a general-purpose and procedure-
oriented language. BASIC can be interpreted and also compiled. You will learn more about BASIC in
this course. Today, we have a number of BASIC language versions which you can use to develop
beautifully designed software packages.

PASCAL

Pascal language was designed in 1971 like BASIC as a teaching language. The language was named
after Blaise Pascal who was a French Mathematician and Philosopher and the inventor of the first
mechanical adding machine.

C or C++

The C language was developed as an improvement of the earlier versions, A and B which were
developed by Bell Laboratories. C language was developed in conjunction with the UNIX operating
Page | 27
system; in fact it is the language of the Unix operating system. The language is lower in level than a
language like Pascal but higher than assembly language. Presently, we have the C++ and Visual C++
languages which are the later versions of the original C language. A good number of big
organisations today prefer C++programmers for their in-house software development because of
the essential features of C++ which are absent in other languages.

COBOL

COBOL stands for "COmmon Business Oriented Language" and was developed in 1960 as a language
suitable for business applications. Except for some big organisations which are unwilling to rewrite
their programs using one of the modern languages, COBOL is almost totally abandoned by
programmers today.

There are a number of other high-level languages; some of these are listed below:

• ADA - named after Augusta Ada Byron, the 1st Computer programmer. It was developed in 1983 by
U.S Defence Department.

• APL - A Programming Language developed between 1962 and 1968.

• PL/1 - Programming Language 1 developed in 1964.

• LOGO - developed in 1966.

• RPG - Report Program Generator, developed in the 1970's.

• LISP - Short for LIST Processor, developed in 1960 as a Special — purpose language designed to
manipulate nonnumeric data.

Page | 28
UNIT 7
INTRODUCTION TO BASIC PROGRAMMING

INTRODUCTION

As you already know in the previous unit, BASIC stands for Beginner's All-purpose Symbolic
Instruction Code. The language was developed in the early 1960s by John Kemeny and Thomas Kurtz
of Dartmouth College, as a teaching language. There are many versions of the language. Examples
are:

i. BASICA - Advanced BASIC


ii. GW BASIC - Eagle BASIC
iii. QBASIC - Quick BASIC
iv. Turbo BASIC
v. Visual BASIC
vi. BASIC 4GL
vii. KBASIC
viii. FreeBASIC
ix. SpeedBASIC
x. ExtremeBASIC
xi. MediaBAS1C
xii. YaBAS1C
xiii. xBASIC
xiv. Liberty BASIC
xv. Just BASIC
xvi. wxBASIC
xvii. smallBASIC
xviii. Gambas

Visual BASIC is a version of the language specially designed for Windows platforms and is today
one of the programming tools with very high preference among programmers. However, it is
interesting to know that BASIC language remains one of the best programming tools gaining
wide acceptance even in the face of rapid developments of various computing platforms.

For example, SmallBASIC has been designed to run on various platforms including Windows,
Linux and Pocket PC platforms. Gambas is designed for Linux operating system, while most of
the versions listed in (vi) — (xvi) are for Windows platforms and they compete favourably with
Visual Basic. Specifically, SpeedBASIC is an attempt to create an object oriented BASIC style
language, similar to Visual Basic, with its own Integrated Development Environment (IDE).

Page | 29
BASIC VARIABLES AND CHARACTERS

The BASIC Interpreter or Compiler handles variables as names of memory locations. Memory can
just be visualised as a Post Office. You know that each Post Office box has an address to identify
it. The contents of the box can change from time to time but the address remains uniquely
unchanged. The same occurs in the computer memory. Now, in addition to identifying memory
locations, variable names are also used to identify the types of data being stored in the
computer memory. Though there are several types of data, in this unit on BASIC, you will only be
introduced to two and hence two types of variables, namely:

• Numeric Variables
• String Variables

NUMERIC VARIABLES: Generally in BASIC, variable names must start with a letter and can be
followed with numbers or other letters, For example, a variable name can be as long as 40
characters (as in MS QBasic). So, examples of variables names are Al, B3, AB4, JONH, REJ2, Y5,
and so on.
Numeric variables are simply those that represent numbers. In BASIC, such numbers can be
whole numbers, decimals, zero, positive or negative integers. In other several programming
languages, you may need to identify specifically the type of the variable, either as REAL,
INTEGER, LOGICAL, COMPLEX or CHARACTER. However, BASIC is a more accommodating
language and most versions may not bother you on identifying the variable type.

STRING VARIABLES Variable names are also employed to represent character data in memGry.
Character variable names are similar to numeric variable names, but they refer to memory
locations containing character
strings, where collections of characters are called String Variables. To specifically distinguish a
string variable, the dollar symbol $ is used at the end of the variable name. Examples of string
variable names are therefore as follows:
A$, JOHN$, B2$, REJ$, etc
It is good for you to also know that the dollar sign $ also appears at the end of almost every
BASIC reserved word that deals with strings. Now, while the values of numeric variables are
simply numbers, the values of string variables are given as characters enclosed between double
quotes, such as "NAME", "OK", etc. the space character can also be made as part of the string.

You may find the following points very helpful as you choose your variable names:

Page | 30
• Keep your variable name as short as possible since you need to type it every time you need it
in your program code (though you can copy and paste, every time).
• Select a meaningful variable name to assist you in remembering what it represents.

Below, you will now see the meanings of some characters or symbols used in BASIC language.
The characters will be grouped for your understanding as follows:
• Alphabetic characters
• Numeric characters
• Data — type Suffixes
• Mathematical Operators
• Special or other characters
ALPHABETIC CHARACTERS
a — z or A — Z That is. BASIC accepts letters A to Z, either in lower or upper cases.
NUMERIC CHARACTERS
0 — 9 and A — F (or a —1) for hexadecimal numbers
DATA-TYPE SUFFIXES
$ String
! Single Precision
# Double Precision
% Integer & Long Integer
MATHEMATICAL OPERATORS
+ Addition
* Multiplication
- Subtraction
= Relational symbol or Assignment symbol
< Less than
> Greater than
. Decimal point
∧ Exponentiation
<> Not equal to
/ Division
<= Less than or equal to
>= Greater than or equal to

Page | 31
\ Integer division
Special car Other Characters
: - (Colon) separates multiple statements on a single line
; - (Semicolon), controls PRINT statement output
, - (Comma) also controls PRINT statement output
‘ - (Single Quote) used for comment line in place of REM.
? - Used in place of PRINT. BASIC also uses it as INPUT statement prompt

You will see the use of some of the above symbols and characters in subsequent units on BASIC
in this course.
Though you will not be introduced to the essential programming languages in this course until later
in your academic programme, however, there are some vital programming languages you will need
to study as a programmer. Examples of these are:

• HTML - Hypertext Mark-up Language

• Java - an object-oriented language

• SQL - Structured Query Language

• VB.net – another object oriented language

Page | 32

You might also like