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

java programming

Programming is the process of writing, testing, and maintaining instructions for computers to solve problems, requiring expertise in various subjects. A good program should be reliable, user-friendly, efficient, and maintainable, while following a structured development cycle that includes feasibility study, design, programming, and implementation. Algorithms, flowcharts, and decision tables are essential tools in programming for representing problem-solving steps and logic.

Uploaded by

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

java programming

Programming is the process of writing, testing, and maintaining instructions for computers to solve problems, requiring expertise in various subjects. A good program should be reliable, user-friendly, efficient, and maintainable, while following a structured development cycle that includes feasibility study, design, programming, and implementation. Algorithms, flowcharts, and decision tables are essential tools in programming for representing problem-solving steps and logic.

Uploaded by

silas danladi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Concept of programming

A program is a set of instructions that tells the computer what to do. Computer programming
(often shortened to programming or coding), is the process of writing, testing,
debugging/troubleshooting and maintaining act of instructions (source code) for solving a problem
with the computer. A source code is written in an acceptable computer programming language.
The code may be a modification of an existing source or something completely new.
The purpose of programming is to create a program that exhibits a certain described behavior
(customization). The process of writing source code requires expertise in many different subjects,
including knowledge of the application domain. Alternatively. Programming is the craft of
transforming requirements into something that a computer can execute. Problem solving on
computer is a task of expressing the solution to the problem in terms of simple concepts,
operations and computer code(program) to obtain the results.
To achieve this aim, you may proceed as follows.
1. First, understand the problem clearly:- Decide what you want to be calculated by the computer.
What will be the input data required? (if any). This is the problem formulation.
2. Write the steps of computation that are necessary to arrive at the solution. This is setting up the
algorithm.
3. Prepare a flowchart corresponding to the algorithm.
4. Develop the computer program. Test and run it on the computer.
There is an ongoing debate on the extent to which the writing of programs is an art, a craft or an
engineering discipline. Good programming is generally considered to be the measured application
art, craft and engineering, with the goal of producing an efficient and maintainable software
(program) solution. The discipline differs from many other technical professions in that
programmers generally do not need to be licensed or pass any standardized (or governmentally
regulated) certification tests in order to call themselves “programmers” or even “software
engineers”.
Features of a good computer program
1) Reliability
Any developed program for a particular application can be depended upon to do what it is
supposed to accomplish. How often the results of a program are correct. This depends on
prevention of resulting from data conversion and prevention of errors resulting from buffer
overflows, underflows and zero division.
2) Meeting Users Needs:
Any developed system has a purpose for which it is developed. A developed program is a
failure if it cannot meet the objectives for which it is proposed and designed, that is, if the
potential users cannot use it either because it is too complex or too difficult. The usability of an
application analysis involving the user.
3) Development on time within Budgets:
Estimates of time and cost for writing computer programs have frequently been under or over
estimated. The components of a structured disciplined approach to programming are:
i) Proper control and management of time and cost required.
ii) Increased programmer productivity
iii) More accurate estimates.
4) Error-Free Set of Instruction
Almost all large set of programs contain errors. If a program is designed and developed in a
disciplined structured approach, it minimizes the likelihood of errors and facilitates
detection/correction of such errors during program testing.
5) Error-Resistant Operations:
A good program should be designed in such a way that it can perform validation run on each
input data to determine whether or not they meet the criteria set for them. Eg Reasonableness
check, Existence check, Dependency check, etc.
6) Maintainable Code:
A good program design will always be easy to change or modify when the need arises.
Programs should be written with the maintenance activity in mind. The structure, coding and
documentation of the program should allow another programmer to understand the logic of the
program and to make a change in one part of a program without unknowingly introducing an
error in another part of the same program.
7) Portable Code:
A good program design will be transferable to a different computer having a language translator
for that language without substantial changes or modification
8) Readability:
The program codes will be easy for a programmer to read and understand the logic involved in
the programming.
9) Storage Saving:
A good program design is not to be verbous, that is, it will not be allowed to be unnecessary
long, thereby consuming much storage that will be required for processing data and storage of
information produced from processing.
10) Efficiency:
The amount of system resources a program consumes (processor time, memory space, slow
devices, network bandwidth and to some extent even user interaction), the less the better.
11) Robustness:
How well a program anticipates situations of data type conflict and other incompatibilities that
result in run time errors and program halts. The focus is mainly on user interaction and
handling of
12) Usability:
The clarity and intuitiveness of a programs output can make or break it’s success. This involves
a wide range of textual and graphical elements that makes a program easy and comfortable to
use.
System Development Cycle
Most IT projects work in cycles. First, the needs of the computer users must be analyzed. This task
is often performed by a professional Systems Analysts who will ask the users exactly what they
would likethe system to do, and then draw up plans on how this can be implemented on a real
computer based system.
The programmer will take the specifications from the Systems Analyst and then convert the broad
brushstrokes into actual computer programs. Ideally at this point there should be testing and input
from the users so that what is produced by the programmers is actually what they asked for.
Finally, there is the implementation process during which all users are introduced to the new
systems, which often involves an element of training. Once the users start using the new system,
they will often suggest new improvements and the whole process is started all over again.
These are methodologies for defining a systems development cycle and often you will see four key
stages, as listed below.
Feasibility Study
Design
Programming
Implementation
Concept of Algorithm
An algorithm is a set of instructions to obtain the solution of a given problem. Computer needs
precise and well-defined instructions for finding solution of problems. If there is any ambiguity, the
computer will not yield the right results. It is essential that all the stages of solution of a given
problem be specified in details, correctly and clearly moreover, the steps must also be organized
rightly so that a unique solution is obtained.
A typical programming task can be divided into two phases:
(a) Problem solving phase
In this stage an ordered sequence of steps that describe solution of the problem is produced.
Their sequence of steps can be called anti-Algorithm
(b) Implementation Phase
In this phase, the program is implemented in some programming languages.
Algorithm may be set up for any type of problems, mathematical/scientific or business. Normally
algorithms for mathematical and scientific problems involve mathematical formulars. Algorithms
for business problems are generally descriptive and have little use of formula.
Features of an Algorithm
1. It should be simple
2. It should be clear with no ambiguity
3. It should head to unique solution of the problem
4. It should involve a finite number of steps to arrive at a solution
5. It should have the capability to handle unexpected situation.
Methods of Representing Algorithm
Algorithms are statements of steps involved in solving a particular problem. The steps to the
solutions are broken into series of logical steps in English related form. Programs are written to
solve real life problems.
There can’t be a solution if there is no recognized problem and once a problem exist, one must take
certain step in order to get a desired solution. The following methods could be used to represent
an algorithm.
Methods of English like form
Methods of Flowchart
Methods of Pseudo code
Methods of Decision table
Methods of Data flow Diagram (DFD)
Pseudo code
A pseudo code is the English-like representation of the program logic. It does not make use of
standard symbols like the flowchart. It is a sequential step by step arrangements of the instructions
to be performed to accomplish a task. It is an informal and artificial language that helps
programmers develop algorithms.
Example 1
Write a pseudo code for findings the area of a room.
Solution:
• Begin process
• Input room length
• Input room width
• Multiply length by width to get area
• Print area
• End process
Solution for example 3 (below under pseudo code)
• Step 1: Input M1, M2, M3, M4
• Step 2: Grade ← (M1 + M2 + M3 + M4)/4
• Step 3: If (Grade < 50) then
• Print “FALL”
• Print “Pass”
• End it.
Example 2
Write a Pseudo code for finding the greatest of 3 numbers represented as A, B, and C.
Solution
• Begin process
• Input A,B,C
• If A>B then big = A
• Else big = B
• If big >C then bigst = big
Else bigst = C
Example 3
Write an Algorithm to determine a student’s final grade and indicate whether it is passing or failing.
The final grade is calculated as the average of four marks.
Solution
• Input a set of 4 marks
• Calculate their average by summing and dividing by 4.
• If average is below 50
Print “Fail”
else
Print “Pass”
English-like form
The English form of representing as algorithm entails breaking down the solution steps of the
problem into
single and sequential English words. The steps are represented in English to say what action should
be
taken in such a step.
Example 1
Develop an algorithm to obtain a book on computer from your school library located on the fourth
floor of
the building. You are to proceed to the library from your ground floor classroom.
1. Start from the classroom
2. Climb the stairs to the 4th floor and reach the library
3. Search a book on computer
4. Have the book issued
5. Return to your classroom
6. Stop.
Note: The above algorithm solution of example 1, has been written in simple and clear English way.
There is no
Example 2
Develop an algorithm to find the average of four numbers stored in variables A,B,C,D
Solution
1. Start
2. Read values in variables A,B,C,D
3. Calculate the average as (A+B+C+D)/4 and store the result in P.
4. Write the value stored in P
5. Stop.
Example 3
Develop and algorithm to find the average of four numbers stored in variables A, B, C, D. When the
value
of variable A is zero, no averaging is to be done.
Solution
1. Start
2. Read values stored in variable A,B,C.D
3. If the value of A is Zero, then jump to step 6
4. Calculate the average of A, B, C, D and store the result in variable P.
5. Write the value of P
6. Stop.
Flowchart
Flowchart is a representation of the algorithm using standard symbols. Each symbols has a new
function. The Algorithm steps determine which symbol to use to represent it in the flow each step
is linked to another step by using the directional arrows.

Example Write an algorithm and draw a flowchart to convert the length in feet to centimeter.
Solution
(Pseudocode)
• Input the length in feet (Lft)
• Calculate the length in an (LCM) by multiplying LFT with 30
• Print Length in Cm (LCM)
Flow Chart Symbols and Flow Chart For Mailing Letter
[Type the document title]
18
Step 1: Input Lft
Step 2: Lcm ← Lft * 30
Step 3: Print Lcm
Step 4: Stop
Decision table
A decision table is a form of truth table that structures the logic of a problem into simple YES and
No form. It is easily adapted to the needs of business data processing. It is a rectangle divided into
four sections called quadrants. It provides a structure for showing logical relationships between
conditions that exist and actions to be taken as a result of these conditions.
The quadrants of a decision table are called the condition steeb, the condition entry, the action
stub and the action entry respectively.

1. The number of condition is used to determine the number of entries by using the formula, where
n is the number of condition.
2. Halving method is used to form the entries in the condition entry e.g if the number of conditions
in a question is 3, then the no of entries will be 23 =8. Therefore in the condition entry box, the first
row will have 4 Ys and 4 Ns. The second row will have 2Ys and 2Ns by 2.Finally the 3rd row will have
1Y and 1N into 4
1 Condition stub:- This gives a list of all the conditions that are relevant to the system.
2 Condition entry: - Shows a YES or NO entry (abbreviated to Y for YES and N for NO) whether listed
condition is present or absent.
3 Action stubs: - This quadrant gives a list of all the actions that could be taken by the system,
based on the conditions.
4 Action entry: - This quadrant indicates whether a specific action will be taken or will not be
taken .
Action stub Action entry
The condition entries
i Y is an indication that the condition is present
ii N is an indication that the condition is not present
iii - or blank is an indication that the condition was not tested.
The action entries
i X is an indication that the listed action to be taken.
ii blank is an indication that the action is not to be taken.
Advantages of Decision Tables
1. They are simple, practicable and economical .All that is regarded to developed a decision table is
a piece of paper and a pencil
2. It makes the system designer to express the logic of the problem in direct and concise terms,
whichresults in the development of an effective and efficient program.
3. It is useful in program documentation i.e decision tables provide a quick and easily understood
over view of the system.
4. It is an excellent communication device to breach the gap between the computer personnel who
are responsible for developing the system and the non data processing personnel who use the out
put of the system.
5. Decision tables are easy to update.
6. It is easy to lean how to use decision table.
7. The complexity and the amount of detail that can be handed by a decision table is un-limited.
Disadvantages
1 Total sequence: The total sequence of an operation is not clearly shown in the decision table i.e
no overall picture is given as with flowcharts.
2 Logic: Where the logic of a system is simple flowcharts always serve the purpose better.
Data flow Diagrams
A data flow diagram shows the flow of the data among a set of components. The components may
be tasks, software components, or even abstractions of the functionality that will be included in the
software system. The actors are not included in the data flow diagrams. The sequence of actions
can often be inferred from the sequence of activity boxes.
Rules and Interpretations for correct data flow diagrams.
1) Boxes are processes and must be verb phrases
2) Arcs represent data and must be labeled with noun phrases.
3) Control is not shown. Some sequencing may be inferred from the ordering.
4) A process may be a one – time activity, or it may imply a continuous processing.
5) Two arcs coming out of a box may indicate that both output are produced or that one or the
other is produced.

The flowchart
A flowchart is a pictorial representation of an Algorithm or of the plan of solution of a problem. It
indicates the process of solution, the relevant operations and computations, point of decision and
other information that are part of the solution. Flowcharts are of particular importance for
documenting a program. Special geometrical symbols are used to construct flowcharts. Each
symbol represents an activity. The activity could be input/out of data, computation/processing of
data, taking a decision, terminating the solution, etc. The symbols are joined by arrows to obtain a
complete flowchart.
Example 1
Draw a flowchart to find the average of four numbers stored in variables A,B,C,D
Solution

Uses of flowcharts
1 It gives us an opportunity to see the entire system as a whole.
2 It makes us to examine all possible logical outcomes in any process.
3 It provides a tool for communicating i.e a flowchart helps to explain the system to others.
4 To provide insight into alternative solutions.
5 It allows us to see what will happen if we change the values of the variable in the system.
ADVANTAGES OF USING FLOWCHART
1. Communication flowcharts are visual aids for communicating the logic of a system to all
concerned.
2. Documentation: flowcharts are a means of documentation because:
3 The analyst/ programmers may leave the arrangement or they may forget the logic of the
program.
4 Changes to the procedure are more easily catered for (modification).
5 Flowchart can be understood by new staff coming to the company
6 Analysis: flowcharts help to clarify the logic of a system i.e the overall picture of the organization
can be seen.
7 Consistency: A flowchart is a consistent system of recording. It brightens @ the relationships
between different parts of a system.
DISADVANTAGES OF USING FLOWCHART
1. Complex logic :- Where the logic of a problem is complex, the flowchart quickly becomes
clustered and lacks clarity.
2. Alterations:- If alterations are required the flowchart may require redrawing completely.
3. Reproduction :- As the flowchart symbols cannot be typed, reproduction of flowchart is often a
problem.
Basic Coding Structures
All computer programs can be coded using only three logic structures (or programs) or
combinations of these structures:
1. Simple sequence
2. Selection
3. Repetition
The three structures are useful in a disciplined approach to programming because
1.The program is simplified. Only the three building blocks are used, and there is a single point of
entry into the structure and a single point of exit.
2. The three coding structures allow a program to be read from top to bottom making the logic of
the program more visible for checking and for maintenance.
Simple Sequence
The simple-Sequence structure consists of one action followed by another. In other words, the flow
of control is first to perform operation A and the to perform operation B.. A simple sequence is
flowcharted as two process symbols connected by a flowline.
Selection
The selection structure consists of a test for condition followed by two alternative paths for the
program to follow. The programs selects one of the program control paths depending on the test of
the condition. After performing one of two paths, the program control returns to a single point.
This pattern can be termed IF .. ELSE because the logic can be stated (for condition P and
operations C and D): IF P (is true), perform C; ELSE perform D . A flowchart for the selection
structure consists of a decision symbol followed by two paths, each with a process symbol, coming
together following the operation symbols.
(a) Single alternative – This structure has the form:
[IF condition, Then:]
[End of IF structure]

(b) Double alternative: This structure has the form

(c) Multiple alternatives: This structure has the form:


IF Condition (1), then
[Module A,]
Else if condition (2), then:
[module Az]
:
Else if condition (m), then;?
[Module Am]

Iteration Logic (Repetitive flow)


The repetition structure can also be called a loop. In a loop, an operation or a set of operation is
repeated until some condition is satisfied. The basic form of repetition is termed DO WHILE in the
literature of structured programming. In some languages, the repetition structure might be termed
PERFORM UNTIL. In the perform until pattern, the program logic tests a condition; if it is true, the
program executes the operation and loops back for another test. If the condition is true, the
repetition ceases.
This structure has the form:
Repeat for K = R to S by T:
[Module]
[End of loop]
Algorithm example for iteration or repetition
For example let us take 10 sets of numbers each set containing three. The problem is to get the
biggest number in each set and print it.
Algorithm
Step 1: Read the total number of sets
Step 2: Initialize the number of the set as N=1
Step 3: Read three numbers of a set say A, B, C.
Step 4: Compare A with 3 and choose the bigger.
Step 5: Compare the bigger number with C and Choose the biggest
Step 6: Print the biggest number,
Step 7: Increment the number of the set by 1 (N=N+1)
Step 8: Check whether we have exceeded 10. If not Go – To step 3. Otherwise.
Step 9: STOP

STAGES OF PROGRAM DEVELOPMENT


Before computer program is successfully written, documented and installed, it must have passed
throughthe following stages. Each stage has something to contribute to the accomplishment of the
whole task.
The stages are:
Problem definition:
Before any reasonable and meaningful program could be written, the problem that prompted it
must have to be defined. No one solves a problem he does not know. The problem to be solved by
computer should be well stated and understood before the solution will be worked out. From the
solution, it is expected that the output of the problem is known and the input will be prepared to
arrive at the output.
Develop the algorithm
An algorithm is a well defined set of instructions that is used to solve a particular problem in a finite
number of steps. It involves unambiguous stating of the procedures and steps necessary to
transform the input data into output. It posses a little difficulty to the program planner, and once
accomplished successfully, the rest of the solution follows easily.
Plan the logic of the program/flowcharting:
The logic of the program will be planned using any of the program design tools it flowchart,
pseudocode or hierarchy chart. The choice of the design tool used depends on the programmer,
but the most popular and most handy is the use of the flowchart to organize the thought of the
program planner and to check for any logic error or misrepresentation. A flowchart is a pictorial
view of the program logic
Write the computer program:
After the design or planning the logic of the program using the flowchart, the next stage is the
actual writing of the program using any of the programming languages in a proper sequence. This is
called, coding of the program. This is done by strictly obeying the language syntax or following the
established rules of the programming language.
Type the program into computer:
The next stage after writing the program, it to key the program into the computer. Any program
that will be executed by the computer must be resident in the computer memory. The typing is
generally made oneline after the other.
Test and debug the program:
The moment the program has been keyed into the computer, the programmer is ready to see if the
program is working. The program could be translated into machine language by either a compiler
or interpreter depending on the language in use ie for BASIC program, when the command RUN is
typed and entered, the program begins executing. If any rules language is broken, the program will
not work. The errors must be removed before the program will start producing the output. Testing
is very necessary to ensure that the correct and required answers are produced as the output.
Document the work:
Documentation helps the user to understand the program better. It identifies exactly the purpose
of the program. It is always referred to whenever changes are to be made in the program to suite
new development. It contains the following parts.
i) A statement of the problem
ii) Algorithm and program plans (ie flowchart, hierarchy chart or pseudocode
iii) Description of input and output
iv) Program listing
v) Test data and results
vi) Technical details and instruction for the user.
All these are assembled into a finished program documentation.
Program development/execution process
The program development stages/process is illustrated in the diagram below;

LEVELS OF COMPUTER PROGRAMMING LANGUAGES


All computers whether small or big cannot do anything on their own. They all require a series of
instructions (i.e programs) before they can do any processing. It is these programs that will direct
the computer to carry out the required task. The programs have to be written out
comprehensively: to cover all possibilities: and in the right order before the control unit of the CPU
can use them effectively.
Programs can be written in several languages. Just as there are many spoken languages, there are
manycomputer languages. In this lecture we shall study the different levels of computer languages
and their forms. Currently all computer languages can be grouped into three, namely, machine
languages, assembly languages and high-level languages. Machine languages and assembly
languages are together referred toas low-level languages. The detail characteristics of each group
of languages are discussed below.
Low-level Languages
These group of languages are so named because in frm they are very close (i.e. similar) to the
language the computer understands, and very remote from languages spoken by human beings.
Low-level languages are in two forms namely: machine language and assembly language.
Machine language
Machine language is as old as the computer itself. It is the computer’ s own language. It consists of
the code that designates the electrical states in the computer (i.e, on or off): this is expressed as
combination of Os and 1s./It is called the computer’s own language because codes or instructions
written in machine language can be executed directly by the computer; without the need for any
translation. This is the only language that has this characteristic.
Each type of computer has its own machine language. That is to say, that different brands of
computers cannot understand programs written in another brand’s machine language. Talking
specifically, a computer made by IBM company has its own language which is different from the
one of NCR company. Even two different models of computers made by the same company do not
usually have the same machine language. Thus programs written in machine language are said to
be machinedependent.
Every instruction in machine language programs must specify both the operation to be carried out
as well as the storage locations of the data items to be used in the operation. In form, it consists of
a series of numbers. The operation part is called opcode or operation code and the remaining part
gives the addresses of the data items in memory that will be affected by the operation. Due to
these special requirements machine language programming is extremely complex, tedious and
time consuming.
For example, the instruction, in machine language, to make the computer add together the
numbers
currently stored in memory address four and seven and then store the sum in address four will look
like this.
1A47
The first two numbers 1A is the operation code for add in IBM 360 machine. On another machine it
will be another series of numbers different from the one given.
For effective and efficient program in machine language, the programmer must keep track of which
memory locations have been used and the purpose of each memory location. Also the programmer
must know every operation code and the action that it causes the computer to take. It is quite
lengthy and tedious. To overcome this, the assembly language come into existence.
Assembly Language
In order to relieve programmers the arduous task of writing in machine language, the assembly
language was developed. It is very much similar to machine language but instead of writing in
series of numbers, convenient symbols and abbreviations are used. Assembly language
programming does not require the programmer to remember numeric opcodes and addresses.
However, it still requires the programmer to be familiar with the operation codes and the methods
of addressing memory locations for that particular machine. This is because, the assembly
language; though at a higher level, still depend very much on the language of that particular
machines.
Programs in assembly language cannot be executed directly, it still has to be changed to the
machine language during execution. Thus we can see that assembly language too is machine
dependent. That is to say, different brands of computers have different assembly language. For this
reason, assembly language is still classified as low-level language.
For the IBM 360 computer the machine language code for ass is 1A while in assembly language,
addition operation code is AR is a mnemonic for “Add Register”. For STORE operation the assembly
code is the mnemonic STO while TRA stands for TRANSFER Operation and MR stands for MOVE
REGISTER operation etc.
Similarly the programmer can assign a name to each memory location. For instance address seven
may be given the name P and address four may be given the name Q, thus the instruction.
AR P. Q
In assembly language will be executed as adding the contents of register Q to the contents of P; of
course the final result will be in register P.
As mentioned earlier, regardless of which assembly language is used, the computer cannot directly
execute the programs written in this language. It has to be translated into the machine language by
another special purpose software called translator. The details of the translation process shall be
studied in later lectures.
High-level languages
As computers have developed in complexity, so have programming languages. High-level language
programming are the result of sophistication in programming languages.
The Machine and Assembly languages discussed before require programmers to construct
programs in a
form that does not follow normal ways of human thinking, communication and language notation.
To
avoid this problem High-level languages were developed. Another name for high-level languages is
[Type the document title]
52
problem-oriented languages. With this language, programmers’ attention are now directed
towards
problem solving instead of operations going on inside computer. These languages allow
mathematicians
and Scientists to use common algebraic notations for coding formulas while other lay programmers
can
write their programs in ordinary sentence form. The time and effort needed to write programs are
now
reduced considerably and programs are easier to correct and modify.
A large number of high-level languages are in use today. In fact, more are being developed daily as
researchers are still going on.
Example of high-level languages commonly in use today include:
1) BASIC (Beginners All-purpose Symbolic Instruction Code)
2) FORTRAN (Formula Translator). There are many versions of FORTRAN However
the modern version is called FORTRAN 77
3) COBOL (Common Business Oriented Language). There are many versions
4) `C’ language
5) PL/1
6) PASCAL (language named after an ancient French Mathematician and inventor of
Pascal engine), etc.
Each of the high-level languages has rules that govern how to write instructions in them. Like
any human language, it is the duty of the programmer or user to learn the rules of the language
he wants to use.
Unlike low-level language which is machine-dependent, high-level languages are machine
independent. That is to say, a program written in any of the high-level languages can be run with
little or no changes by computer made by many different manufacturers. Thus, as new computers
come into existence, programmers do not have to rewrite the existing programs and learn new
language as it is the case with assembly programming.
The example below shows how to add two numbers held in variables X and Y placing the sum
in X using the most common four high-level languages.
BASIC……. LET X = X + Y
FORTRAN ……. X = X + Y
COBOL………. ADD Y TO X
PASCAL…….. X: = X + Y
It can be observed that the notation is very similar to human ways of thinking and expression
and very remote from the machine language.
MACHINE LANGUAGE
Machine Code or machine language is a low-level programming language that can be understood
directly by a computer’s central processing unit (CPU). Machine code consists of sequences of
binary numbers, or bits, which are usually represented by 1s and 0s, and which form the basic
instructions that guide the operation of a computer. The specific set of instructions that constitutes
a machine code depends on the make and model of the computer’s CPU. For instance, the machine
code for the Motorola 68000 microprocessor differs from that used in the Intel Pentium
microprocessor.
Writing programs in machine code is tedious and time-consuming since the programmer must keep
track of each specific bit in an instruction. Another difficulty with programming directly in machine
code is that errors are very hard to detect because the program is represented by rows and
columns of 1s and 0s.
Advantages of Machine Language
1) Less code is produced
2) Storage is saved
3) User has direct control of machine instruction
4) Execution is faster as no translation is needed
5) The programmer knows all the registers and instruction that use them.
Disadvantages of Machine Language
1) Cumbersome ie, tedious and difficult to learn
2) Programmer’s fluency is affected, thereby making the programs developed inefficient.
3) The developed programs are error prone and difficult to debug (correct)
4) The performance of the system is unreliable.
ASSEMBLY LANGUAGE
Assembly language is type of low-level computer programming language in which each statement
corresponds directly to a single machine instruction. Assembly languages are thus specific to a
given processor. After writing an assembly language program, the programmer must use the
assembler specific to the microprocessor to translate the assembly language into machine code.
Assembly language provides precise control of the computer, but assembly language programs
written for one type of computer must be rewritten to operate on another type. Assembly
language might be used instead of a high-level language for any of three major reasons: speed,
control, and preference. Programs written in assembly language usually run faster than those
generated by a compiler; use of assembly language lets a programmer interact directly with the
hardware (processor, memory, display, and input/output ports).
Assembly language uses easy-to-remember commands that are more understandable to
programmers than machine-language commands. Each machine language instruction has an
equivalent command in assembly language. Assembly language makes programming much easier,
but an assembly language program must be translated into machine code before it can be
understood and run by the computer.
Special utility programs called assemblers perform the function of translating assembly language
code into machine code. Like machine code, the specific set of instructions that make up an
assembly language depend on the make and model of the computer’s CPU. Other programming
languages such as Fortran, BASIC, and C++, make programming even easier than with assembly
language and are used to write the majority of programs. These languages, called high-level
languages, are closer in form to natural languages and allow very complicated operations to be
written in compact notation.
Advantages of Low Level Language
1) Program translation is easier than high level language
2) It affords the programmer the opportunity to understand the internal structure of the
hardware and its registers.
Disadvantages of Low Level Language
1) It is machine dependent, That is, cannot be transferred to another computer.
2) Program development is slow as the programmer must have detailed knowledge of the
hardware structure.
3) Program maintenance is slow and error prone.
HIGH LEVEL LANGUAGE
High-Level Language is a computer language that provides a certain level of abstraction from the
underlying machine language through the use of declarations, control statements, and other
syntactical structures. In practice, the term comprises every computer language above assembly
language. The next generation of language is called the 3rd generation. The computer
programmers enjoy using this language because it gives them the fluency, the flexibility and the
opportunity to express their thought to the best of their ability. The languages of this generation
are called High level language. The high level languages are referred to as machine language and
assembly language.
Advantages of High Level Language
2) It makes programming easier for the human being.
3) High level instructions are easier to understand and faster to code.
4) Error correction and resting of program is easier
5) They are machine independent. That is, program written for computer can be transferred to
another computer with little or no modification.
Disadvantages of High Level Languages
1) High level language tends to be inefficient in the use of CPU and other facilities.
2) Machine code instructions are produced and then requires more storage spaces.
3) More time is required to run the program as it has to be translated.

You might also like