Definitions
Computer programming is the aspect
of translation of user’s ideas in to a form that can be understood by the
computer by the use of an acceptable tool called computer programming language.
A computer program is a set of
coded instructions for the computer to obey and process data.
Programming language is set of
instructions or a tool used for writing computer programs.
NB the purpose of computer
programming is to solve the users needs i.e. developing instructions for the
computer with the aim of solving a particular user problem. This enables the
computer to accept and manipulate data and print results automatically.
Primary function of programming
languages is to provide instructions to the computer system so that it can
perform a processing activity. Each programming language uses a set of symbols
that have special meaning. Each language has its own rules called syntax of the
language. The language syntax dictates how the symbols should be combined into
statements capable of conveying meaningful instructions to the CPU.
Programming
languages can be grouped into the following major categories:
They are the
most basic level of programming languages. In the early stages of computer
developments, all program instructions had to be written using binary codes( O’s and 1’s) , unique to
each computer. This type of programming involves the difficult task of writing
instructions in the form of strings of binary digits (ones & zeros) or
other number systems. In this type of programming language data and
instructions were all made in O’s and 1’s which made it difficult to locate and
differentiate. Programmers must have a detailed knowledge of the internal
operations of the specific type of CPU they are using. For this reason
programming work was left to hardware engineers who had internal knowledge of
the computer. They must write long series of detailed instructions to
accomplish even simple processing tasks. Programming in machine language
requires specifying the storage locations (memory address) for every instruction
and item of data used. Execution of instructions was done in the order in which
they occurred in the main storage. These requirements make machine language
programming a difficult and error-prone task. A machine code instruction is
made up of two parts:
i.)
The operation code: It
instructs the computer on what to be done
ii.)
Operand code: It
instructs the computer on the address of the memory location whose contents are
to be worked upon.
Advantages
i.)
The instructions written using this language are
executed very fast because no translation required.
ii.)
There is efficient use of the C.P.U as this
instructions do not occupy large memory space
Disadvantages
i.)
Both data and instructions are expressed in binary
digits hence difficult to differentiate
ii.)
The programs are lengthy and time consuming
iii.) The
programs are machine dependent hence difficult to be executed by different
machine
iv.) Programs
are error prone.
Assembly languages are the next
level of programming languages. They were developed to reduce the difficulties
in writing machine languages programs. Programs were written using symbols to
represent the instructions (symbolic representation of machine code). Assembly languages
are frequently called symbolic
languages, because symbols are used to represent operation codes and
storage locations. Convenient alphabetic abbreviations called mnemonics ( memory aids) and other
symbols are used to represent operation codes, storage locations, and data
elements example Sub for subtraction com for computer add for addition e.t.c.
the symbolic address are used in place of machine address. Comments can be
incorporated in the programs statements to make it easier to be understood by
the human programmer. It become possible to include macros and subroutines on
programs. A macro is a single instruction written as part of a program and
generates many machine code instructions. The use of assembler languages
requires language translator programs called assemblers, which allow a computer
to convert the instructions of such languages into machine instructions. The
process of translating a program is as follows:
- The assembler translates the symbolic operation codes
into machine code and symbolic address into actual machine address. This
is done on the basis of one to one mapping.
- During the process it includes the necessary linkages
for closed sudroutines and program macros.
- The assembler allocates areas in the main memory
- The assembler then indicates any invalid source
language instructions.
- Produces the object program on disk or tape.
- It then produces a printed listing of the source code
together with comments
NB Assembler languages are still
widely used as a method of programming a computer in a machine-oriented
language. Most computer manufacturers provide an assembler language that
reflects the unique machine language instruction set of a particular line of
computers. This feature is particularly desirable to systems programmers, who
program system software (as opposed to applications programmers, who program
applications software), since it provides them with greater control and
flexibility in designing a program for a particular computer. They can then
produce more efficient software – that is, programs that require a minimum of
instructions, storage, and CPU time to perform a specific processing
assignment.
a)
In an assembly language, alphabetic abbreviations that
are easier to remember are used in place of the actual numeric addresses of the
data.
b)
It is readable both by man and machine
c)
These programs run faster because they are machine
specific and closer to machine code.
d)
It is concise with few instructions and consequently
needs smaller storage space for the code.
e)
It is quite efficient with translation time, execution time and storage
requirements.
Disadvantages
a)
Assembly language is machine dependent hence it is not
portable and compatible between various computer systems.
b)
Assembly language is hard to learn compared to high
level languages.
c)
Program takes longer to code due to intricate nature of
the language.
d)
Each computer has a different language and retraining
programmers presents a problem whenever a company acquires a new computer.
e)
It makes stand by arrangements in case of breakdown
difficult because work cannot be run on a different computer.
f)
It lacks debugging aids.
High
level languages allow problems to be specific in a human and problem oriented
manner. The programs of high level languages are very close to human language
or the standard notation of mathematics hence it is easy to learn and use. The
instructions of High level languages are called Statements and closely resemble human language. Individual
high-level language statements are actually macro instructions; each individual
statement generates several machine instructions when translated into machine
language by high-level language translator programs called compilers or interpreters.
High-level
language statements resemble the phrases or mathematical expressions required
to express the problem or procedure being programmed. The syntax (vocabulary,
punctuation, and grammatical rules) and the semantics (meaning) of such
statements do not reflect the internal code of any particular computer.
The
development of high level languages was intended to overcome the main
limitations of the low level languages. The high level languages are therefore
machine independent and problem oriented .i.e. they reflect the type of problem
being solved rather than the features of the machine. The machine independence
of high level languages means that it is possible to make a program that can be
run on different machines i.e. program portable.
The
portability of a program has the following advantages:
i.)
A user of a program can easily change to newer or
bigger computer without the need of re-writing the program again.
ii.)
Users of different computers can exchange programs.
iii.) Users
can develop programs and sell them to different organizations.
iv.) Portability
has enabled the coming up of software companies which develop and maintain
programs for companies and individuals.
High level languages can be categorized
into the following groups
These
are programming languages that were created to be used in commercial firm’s
.i.e. in business. The most common commercial language is COBOL( COmmon Business Oriented Language. It is the most widely used
programming language for business applications.
COBOL has an extensive file
handling facilities e.g. movement and processing. The language resembles
English. .i.e. it incorporates common English terms such as MOVE ADD
Another example
of commercial language is RPG :
(Report Program Generator). A problem-oriented language that generates programs
that produce reports and perform other data processing tasks. It is a popular
language with many business minicomputer users.
These are programming languages
that are used for scientific and engineering purpose e.g.
ALGOL :
(ALGOrithmic Language). An international algebraic language designed
primarily for scientific and mathematical applications. It is widely used in Europe in place of FORTRAN.
FORTRAN : (FORmula TRANslation). The
oldest of the popular high-level languages. It is still widely used for
scientific and engineering applications.
These
programming languages have extensive mathematical and computation ability. They
also have a large library of inbuilt mathematical functions.
These are
programming languages intended to be tailor made language for particular type
of problem e.g machine control, simulation and control of experiments e.g
- Coral 66
- IRTB(Industrial
Real Time Basic ) used
for real time applications.
- Modular 2- it
was developed for development of computer systems.
- Ada
: Named after Augusta Ada Byron, considered the world’s first computer
programmer. Developed for the U.S. Department of Defense as a standard
“high-order language” to replace COBOL and FORTRAN.
These
are languages used to solve both business and scientific problems. Examples
include the following:
APL : ( A Programming Language). A
mathematically oriented interactive language. It utilizes a very concise
symbolic notation designed for efficient interactive programming of analytical
business and scientific applications.
BASIC : (Beginner’s All-Purpose
Symbolic Instruction Code). A simple procedure-oriented language widely used
for end user programming.
C : A mid-level structured language
developed as part of the UNIX operating system. It resembles a
machine-independent assembler language and is presently popular for system
software programming and development of application software packages.
Pascal : Named after Blaise Pascal:
Developed as a powerful successor to ALGOL, and designed specifically to
incorporate structured programming concepts.
PL/1 :
(Programming Language/1). A general-purpose language developed to
combine some of the features of COBOL, FORTRAN,ALGOL, and other languages. It
is a flexible language used for business and scientific applications.
VAR score, sum,
average, count: real;
Infile, outfile: text
BEGIN
Sum: = 0, 0, count, 0, 0;
REPEAT
Read{infile, score}
Sum: = sum + score;
Count: = count + 1.0
UNTIL eof {infile}
Average: = sum/count;
Write{outfile. ‘Average score is’
average}
END
1)
They are problem oriented languages that can be used to
solve any problem.
2)
They are human readable language, easy to learn with
English like statements.
3)
They are machine independent languages which can run in
many computer i.e. they are portable
4)
High-level languages have less – rigid rules, forms,
and syntaxes, so the potential for error is reduced
5)
They encourages mobility among programmers because the
languages syntax for most computers is uniform with manuals easy to follow
6)
High level languages have programming and debugging
aids suitable even for non computer specialists to use when designing programs
or systems.
7)
Most software widely used, such as applications systems
and operating systems sold on the software market are written in high level
languages
Disadvantages
1)
It requires a lot of coding. The programs are lengthy
even for smaller problems.
2)
High-level
language programs are usually less efficient than assembler language programs.
3)
High-level
language programs require a greater amount of computer time for translation
into machine instructions.
4)
Sometimes, human words and phrases may have different
meanings in different contexts due to many company software developers.
In compilation a program called a
compiler takes the source program and translates into machine code in
interpretation a program called interpreter maintains control over both
translation and execution.
It takes an input the source program and interleaves translation and
execution so that the generated code corresponds to the source program.
This means that each statement is translated and executed before the
next statement is translated and executed
Advantages of compilation over
interpretation
1.
In compilation the translation is separated from the
execution. Therefore no execution time is spent performing translation from
source code to object code.
2.
In compilation each source language statement in
translated into machine language at ounce while in interpretation translation occurs each time
the statement is executed therefore there
is a translation and execution and translation of the statement for the
many times the statement is executed.
3.
During optimization the compiler analyzes groups of
statement or subprograms in the source programs and improves the efficiency of
the target program.
Advantages of interpretation
- Interpretation
provides interactive environment where the user can evaluate statement and
expression individually this provides immediate feedback.
- Interpreters usually provide better run-time errors
because the source code is available during execution.
- Interpreters are generally easy to write than
compiler.
- Interpreters can be stored in Read only memory.
d) Fourth generation languages (4GL’s)
This refers to a variety of programming
languages that are more non-procedural and conversational than prior languages.
They are nonprocedural languages that encourage users and programmers to
specify the results they want, while the computer determines the sequence of
instructions that will accomplish those results. Users and programmers no
longer have to spend a lot of time developing the sequence of instructions the
computer must follow to achieve a result. Thus 4GL’s have helped to simplify
the programming process. Natural
languages are 4GL’s that are very close to English or other human
languages. Research and development activity in artificial intelligence (AI) is
developing programming languages that are easy to use as ordinary conversation
is one’s native tongue. 4GL language contain distinct syntax for controls and data structures 4GL may
however represents data structures at a high level of obstruction by
eliminating the need to specify algorithms.
Ø
4GLs contains the following modules
1)
Dialog Editor-
creates true windows dialog s with mouse and saves the source code.
2)
Form designers
– Contains powerful forms for designing controls and pages using design
assistant.
3)
Report Designers-
Creates relational reports that include graphics, multiple fonts and complex
formatting with ease.
4)
Menu Editor -
uses the best easiest and the fastest menu editor with integrated drag and drop
and when done the menu is saved in source code.
5)
Icon Bar Editor
– Creates icon bars for your application.
6)
Macro Recorder
– uses super object basic language etc.
Other features are
E-mail, template, encryption and object oriented programming.
Examples of 4GLS are Paradox, FoxPro, Access,
Dbase, Clipper system c, Sycero, Jackson’s
pof and Oracle.
Advantages
and disadvantages
There
are major differences in the ease of use and technical sophistication of 4GL
products. For instance, INTELLECT and CLOUT are natural query languages that
impose no rigid grammatical rules, while SXQL and FOCUS requires concise
structured statements. However, the ease of use of 4GLs is gained at the
expense of some loss in flexibility. It is frequently difficult for an end user
to everride some of the prespecified formats or procedures of 4GL. Also the
machine language code generated by a program developed by a 4GL is frequently
much less efficient (in terms of processing speed and amount of storage
capacity needed) than a program written in a language like COBOL. Major
failures have been reported in some large transaction processing applications
programmed in a 4GL. These applications were unable to provide reasonable
response times when faced with a large amount of realtime transaction
processing and end user inquires. However 4GLs have shown great success in end
user and departmental applications which do not have a high volume of
transaction processing.
Some people use 5GL’s to describe languages
using artificial intelligence techniques to accomplish results for users. Some
also refer to Tool kits ( appeared in mid 1998) as 5GLs. They combine
rules-based code generation, component visual programming techniques, reuse
management and other advances. 5th
GL LISP, PROLOG and Object oriented languages, were for use in the 5th
generation super computers initially by the Japanese.
- These languages are designed to generate program code
with fewer instructions than the prior languages.
- Programs and applications based on these languages
can be developed in much shorter time.
- The programs are concerned with what the result will
be rather than how it will be arrived at.
- Simple features of this language can be employed by
end user.
- The languages are designed as productive tools for
professional programmers.
1.
Are programmers
familiar with the language. Programmers experience is considered. Best known
frequently used is usually selected.
2.
What’s the nature of the application or type of
application being developed?
3.
Easy of learning & use of the language.
4.
Features or facilities available in a programming
language.
5.
Does the language support structured programming
concepts? Cobol, PL/1, ALGOL & Pascal are better able to support structured
programming than most existing Basic or Fortran dialects.
6.
Is satisfactory translating software available? A language
is a humanly convenient set of rules, conventions, and representations used to
convey information from human to machine. A good language & efficient
translator yields satisfactory results.
7.
Language used in other programs within the
organization.
8.
How often will the application be processed? The faster
the possible programming time is (with high-level or 4Gl), the more economical
the approach. An assembly language program written by a clever programmer
usually has a shorter production run time and takes less storage space than a
program of same application written in high-level language.
9.
Will the program be changed frequently? The ease of
program modification varies with different languages. High-level languages are
easier to modify than assembly language.
10. Is
hardware change anticipated during the life of the application? Conversion of
standardized high-level languages programs is easier and faster.
Machine-oriented programs may have to be completely rewritten.
11. Is
the language being supported, improved and updated? Are resources available for
support, improvement and updating the language.
structured design entails
developing a program as a series of
independent sections for the purpose of performing one task .Structured
programming involves the use of facilities such as IF, THEN, ELSE REPEAT,UNTIL,
WHILE-DO and for –DO. Statements. This approach enables program errors to be
localized and assist in the maintenance of each section.
This is an unformalized approach to
programming. It refers to large undisciplined approach. It has no advantages.
It is a total program approach where all sub programs are planned together as a
logical application. It has a conventional approach which is unsystematic in
treatment and it can be unwieldy but it is common among amateur programmers. It
is only unstructured method.
Refers to development of a modular
basis under this method; the program is broken up in more manageable units.
Each unit represents a major uniquely identifiable component of a program
called a module can be written separately almost identifiable of others but are
a coordinated basis. This approach facilities the debugging (detecting errors)
and maintenance of a program. It also enables a large program to be developed
in a shorter time by a team of programmers thus making the work load lighter.
The modules can be used in house keeping input, processing and output
functions. In good programming practical program modules form a group of
sources code which translates into subprograms such as subroutines procedures
or functions?
1)
Modular programming has the following advantages.A
program can be developed into separate sub programs called modules
2)
It facilitates the development a programs by terms of
programmers.
3)
System modules
can be written and tested independently
4)
It makes debugging of programs a lot easier because
errors are localized in modules.
5)
Programs can be
developed in a shorter time.
6)
Modules ounce
compiled can be imported and exported to other programs written in the same
language or different languages.
In a top down design macro structures of main
program is written first and the lower and lower subprograms are written in
stepwise structured modular decomposition
In bottom-up design the lower
subprograms are tested and debugged in other words top-down development creates
a high-level logic complex structure and all important program or system
interfaces first before a great deal of detail code has been written. It is mostly used in new
systems. It saves time wasting and helps to avoid costly problems of
interfacing. Empirically the bottom –up development tends to run into interface
problems, especially when you have to put together programs systems modules
written by different teams of programs there are three problems.
a)
They tend to involve more changes to existing code that
say logic “bugs”, in that one error in
calculation is carried on to another
part of the program.
b)
They tend to be found one after the other.
c)
In bottom-up development, interface bugs (problems) are
found after most of the task. Or project budget and most of the time have been
spent and when the deadline for delivery of the system or program is near or
past.
In object oriented programming,
data is declared as part of the code with object oriented programs data and
code, that is methods that operation on your data together that can be treated
as a unit to objects=code + data . While other programming languages separate
data elements from the procedures or actions that will be performed upon them,
OOP languages tie them together into objects. In procedural languages, a program
consists of procedures to perform actions on each element, whereas in OOP,
programs tell objects to perform actions on themselves.
Object – oriented languages like
Objective C, C++, visual basic, visual C++, are easier to use and more
efficient for programming the graphics-oriented user interfaces required by
many applications. Once objects are programmed, they are reusable
The three features of OOP are_
(a)
Encapsulation
is the ability to combine data and code (procedures) that operate on it onto
self-contained entities called objectives.
(b) Inheritance is the ability for one
object (parent) to have attributes similar to another object (offspring).
(c)
Polymorphism
gives the code ability to act on many different objects, or be shared by many
different related objects.
The main benefits of OOP are
a)
Simplification- Designing a program is easier , because
corresponding more closely to real world entities.
b) Reusability- Because
objects are related so closely to the data they operate on , it is possible to
reuse old ,reliable objects in new programs .
c)
Repairbility- while updating programs based on object
oriented technology, objects isolated programs functions from each other so
that a change in one does not change program operation elsewhere.
Some of the advantages that are
also advanced in favors of OOP are faster and smaller programs, which are
easier to maintaining object-oriented programming for windows, the basic object
is a window, such as a project window, form window and properties window. Common
objects include controls forms and application programs
Object-Oriented languages
. They have become more popular because
of this.
(g) Visual programming
Visual programming is structured
objects-oriented programming in windows based on ready made objects. It
comprises a collection of procedures that responds to other procedures that
performs specific tasks such as event procedures and general procedures. It is
also event –driven programming in
that all the activities in the program are triggered by one event or another,
such as click and key press. Each object has its own event handling procedures.
An event procedure executes when an
event associated with the application occurs whereas a general procedure contain code which performs common functions and
can be used by other procedures. Procedures can be either public (used throughout the program) or private (limited to the procedures where it is defined).
The difference between object-oriented programming (OOP) and
event-driven programming is that OOP involves round-made objects whereas in
event-driven programming activities in the program are trigged by one event or
a more such as click and key in input.
- Problem
identification. The task to be performed must be identified fully and
clearly, taking into account all the details necessary. Understanding the
problem facilitates definition of the user’s requirement and problem
planning.
- Problem design.
These involve identifying the task and arrange them in order to solve the
problem. A design tool is chosen to describe the problem logic e.g. a
logarithm, flowchart, decision table and tree. The task can be divided
into a number of small operations so that each can be implemented by a
segment of the program.
- Program
coding/writing. Coding is the process of reducing or converting pseudo-code,
a logarithmic instruction, decision tables, flowcharts etc to a series of
program statements in a given computer language. These languages to be
used depends on the nature of the program.
- Compile and
debug the program. compiling is the process of converting the source
program in to objects using a translator such as a compiler or
interpreter. Debugging is a process of identifying and removal of errors
in a program. This involves the use of debugging aids such as a debugger
or tracer. The machine code is precise primitive operation which can only
be understood and implemented by a machine.
- Testing the
program. Testing is the process of ensuring that the program is
correct or serves the users interest or expectation. Testing is where a
program is loaded or submitted with test data that is “artificial data”
and job control statements. Test data should be created by the programmer.
This involves reading input, processing the data and outputting the
results.
Importance of testing
Ø
The trend towards a high degree of integration
of system within an organization
requires that each new system, or program, implemented successfully, be well
tested.
Ø
The increased dependency upon computer generated
information by all levels within organizational activities, relates
organization decision making and problem solving.
Ø
The increased usage and familiarity within
computer based system has resulted in higher expectations by organizational
users of the system or
Programs
6 Program documentation. Documentation is the creation and
maintenance of significant information about program, system etc in a clear and
concise manner or information itself. The purpose of documentation is to build
a complete description of the problem you are trying to solve, the method of
solving the problem and the computer program which incorporates that program.
Documentation also represents a functional description of a program and it
serve as a set of specifications to the programmer. It is also used to in
program validation.
NB: Documentation should take place continuously throughout the
programming process.
There are two categories of
documentation – internal and external
Internal- is technical in nature and is contained in
the program itself. It is addressed to the programmer who might be faced with
the task of modifying the program at some stage. It contains comments or
remarks to make the program easier to read and follow the program logic,
especially for non-programmers.
External- is a separate
documentation with the various contents such as program specification, program
listing etc for various users management and other interested parties.
7. Implementation
stage. Implantation is the process of putting in place the new written
program. It involves the training of users of the program and installation to
the users computer.
Program specification is a detailed
specification for each program defining the defining the problem of each
program designed to each programmer to write program specification involves the
following four major steps.
(i)
Program
definition: To be able to define the problem it is important to understand
the problem to enable good planning of the solution. This means the programmer
shall establish what program is required to do.
(ii)
Input: after
defining the program the programmer is required to decide on the input and data
structure to used in solving the problem. It also important to decide on the
data format and method of data entry depending on the program requirements.
(iii)
Processing:
The processing in the program depends on the information or output requirements
and type of data input. Success of processing will entirely be on the program
effectiveness. If the data is wrong and program is not effective then the
desired output can’t be achieved.
(iv)
Output:
Output format should be specified in program structures and depends entirely on
input format and processing.
Program
specification has the following benefits
(i)
It provides an opportunity for the analyst to rethink
the system design at a detailed low-level.
(ii)
It provides a vehicle for communicating with
programmer.
(iii)
It provides a permanent record which describes or
documents the activities performed by each program in the system.
(iv)
It serves has a guide for program testing after
completion.
(v)
It provides a guide to the programmers.
a)
Integrity: This refers to the accuracy of calculation.
It should be clear that all the other program enhancement will be meaningless
if the calculation are not carried out correctly
b)
Clarity:
This refers to overall readability of the program with particular logic. If a
program is clearly written it shall be possible to any programmer to follow the
program logic without a due effort.
c)
Simplicity:
The clarity and accuracy of a program usually enhance by keeping things as
simple as possible and consistent with overall problem objectives.
d)
Efficiency: It’s is concerned with execution speed and
effectiveness memory utilization. This is important but should not be obtained
at expense of clarity and simplicity.
e)
Modularity:
Most large programs can be broken down into a series of identifiable sub-tasks.
These sub-tasks will be implanted as separate program modules.
f)
Generality:
The programmer is suppose to make the program as general as possible within
measurable limits e.g. you may design a program to read in the values of a
parameter other than placing fixed values into the program
The following are errors that can
be found within a program:
a) Syntax error:
This
are errors encountered when the source program is being compiled from the
higher level language to machine code (object code) the compiler or interpreter
generates error diagnostic indicating the type of errors in the program. These
arrors must be corrected before the further execution of the program is done.
Interactive compilers produce errors after every statement which has such
errors whereas batch compilers list the errors at the completion of the
compilation process.
b) Logic errors
They
are also known as program errors. They represent errors in the logic of the
program. They are not signaled by the compiler but the user will have to assess
the output of the program in order to determine whether it meets the
expectation of the programmer. It is also important to check performance of the
program especially where conditions are invoked and repetition. When the
programmer dry runs the program or assesses the output then this kind of error
can be noted and corrected.
c) Run time errors
These
are errors which occur during the execution of the program. They are directed
during the validation and verification of the input. For instance the filed of
type character is accepted in the field of type numeric or an attempt to divide
by zero. Run time errors occur if the data input is not within the boundary of
the range.
A
major step in problem solution involves determining how to convert input into
desired output, once the program has been designed has been designed. A list of
instruction specifying an ordered sequence of operation that produces the
answer to a given type problem and terminated after a finite number of steps is
called algorithm. Or we can describe an algorithm as a complete set of
instructions that constitutes a solution to problem. Algorithms will vary in
number of steps, logical sequence and formula if any is used to solve the
problem.. as a rule of thumb an algorithm
must have the following properties.
i).
Consists of a finite number of steps that terminate
ii).
Consists of precise and unambiguous instructions.
iii).
Be general enough, that is flexible to be applied to
any problem
iv).
Produce results
Example
1
Write an algorithm to solve the
following problem
(T-32)5/9=Tc
Solution
1)
Subtract 32 from T
2)
Multiply the difference above by 5
3)
Divide the product in 2 above by 9
Example
2
Write an algorithm for calculating
the area of a triangle given the height and the base
1)
Start
2)
Multiply the base and the height
3)
Devide the product by 2
4)
Output the area.
5)
Stop
Example
3
Write algorithm that could be used calculate
the average mark for ten students
1)
Start
2)
Add the marks of the ten students to find the total
marks
3)
Divide the total marks by ten
4)
Stop
Pseudo code is a
narrative description of the steps involved in the executing a computer program
in the order in which they will be executed. It is written in form of an
outline with indent showing the basic programming mechanisms of structural
programming.
Example
1
Write a pseudo code to solve the
following problem
(T-32)5/9=Tc
Solution
Program (input,
output)
Declare variables
Input the
temperature (T)
Calculate
TC(TC=(T-32)*(5/9))
Output the TC
End
Example
2
Write a pseudo code for calculating
the area of a triangle given the height and the base
Program(input,
output)
Declare variables
Base and Height
Begin/start
Read/input base and height
Calculate area (AREA= ½*Base* Height)
Write/output Area
End/stop
Example 3
Write a pseudo code that could be used
calculate the average mark for ten students
Program(input,
output)
Declare variables
totalmarks, marks, average, counter
Begin/start
Initialize totalmark and counter to zero
(counter=0, totalmark=0)
Repeat
Read/input mark
Add mark to
totalmark(totalmark=totalmark+mark)
Increase counter by one
(counter=counter+1)
Until counter = 10
Calculate the
average(average=totalmark/10)
Output the totalamark
Output average
End/stop
Flowchart
is a graphical representation of a solution to problem which symbols are used
to represent operations, data flow and decision. It also shows the relationship
mong statements in the program. Its purpose is to show the information flow and
tools used in problem solving.
Flowchart symbols
1) input-output symbol
The input-output symbol is a
parallelogram which specifies the particular input/output operation. It is used
to enter data into the computer or to print information.
2) Processing symbol
The processing symbol is a general
operation symbol encompassing any type of data manipulation or calculation.
Operation such as move, multiply, add, subtract, sort, merge manual operation
etc
3) Direction symbol
An
arrow represents the flow direction of execution of defined operation. A flow
direction therefore specifies the net single operation, once the current
operation has been performed.
4) Decision Symbol
The
decision symbol is a special diamond symbol that is used to indicate a point in
a program where more than one direction of flow may occur after a processing
operation.. The occurrence of two or more paths is called branching and the
decision block will specify which of the paths will be taken, once the
processing activity is completed
5)
Terminator Symbol
The terminator
symbol represents any symbol at which a program originates or terminates. It
specifies the start and stop of execution.
6)
Connector
The connector is
an oval symbol used to represent an exit from one part of the program or an
entry into another point. They are connectors are:
i).
Off page
connector
Transfers a
activity to another page
ii).
On page
connector
Transfers control/activities
on the same page.
7)
Manual
operation symbol
This symbol
represents a work done manually without use of machine or computer.
Assignment
Research on other symbols used for
flowchart
Factors to consider when drawing
flowcharts
a)
Spacing
Flowchart may be
drawn any standard page size, if required leave a adequate margins and gutters
on all sides of the page for binding. Leave adequate space between flowchart
symbols.
b)
Labeling
Flowchart should
be labeled at the top or bottom with the name of the system, system or program
to which it relates.
c)
Sequence of symbols
The normal flow of
operations is from top to bottom and from left to right. Whenever possible draw
the direction of logic or data flow from top to bottom and from left to right,
however, the directions may be altered by inserting decision symbols.
d)
Accuracy
The symbols should
be drawn to scale as accurately as possible. Although symbols may vary in size,
their shape should remain proportional. Use a template.
e) Neatness
The flowchart should
be neatly drawn to convey a meaning. A flowchart over crowded with to many
lines becomes difficult to flow.
Advantages of Flowcharts
a)
They require less writing
b)
They are easy to follow once you understand the
symbols.
c)
They are independent of any language.
d)
They are applicable in may areas
e)
They are easy to modify
Disadvantages
a)
They are time consuming
b)
They can be quite messy in complicated systems.
c)
They take more paper for drawing than an algorithm for
the same problem.
d)
They are no obvious mechanism for progressing from one
level of design to the next e.g from system flowchart to program flowchart..
e)
They are not easy to read like algorithm
f)
They call for expertise to draw systems accurately even
with the help of a template.
g)
They do not contain enough detailed information and
therefore it becomes difficult for beginners to understand.
Uses of flowcharts
(i).
Communication tool
A flowchart is
convenient tool for communication ideas and concepts among engineers, managers,
it personnel e.t.c. It provides a concrete visual medium for describing complex
plans or problems
(ii).
Planning tool
The flowchart is a
flexible tool when planning and designing a new system. It enables designers to
draw concisely on paper, the essence of a system and its flow lines. It helps
to visualize the relationship and movements that will exist within a system,
while it is still in the planning stages.
(iii).
Define roles
A flowchart spells
out in pictorial form the role played by the personnel, work stations and
process in a system. It points out where the data and forms are generated, the
end results or reports are produced and the people, producers and places
related to the process.
(iv).
Demonstrate relationships
A flowchart points
out relationship that may not be readily obvious from a verbal description. It
shows how parts of system relate to each other as well as specifying the
sequence of data flow.
(v).
Document system
A flowchart
records graphically, formally and permanently the important elements of a
system. This facilitates making changes, revision and modifications at a later
date. It enhances those unfamiliar with a given system to grasp its major
elements easily and quickly.
(vi).
Training tool
It is a good tool
for training new staff on existing systems and programming standards.
(vii).
Design tool
It it used in designing
programs and systems
(viii).
Provide an overview of the system.
A flowchart gives
a birds eye view of the major steps and processes in a system..
thank you sir and i would request that you add more notes for programming to help me
ReplyDelete