Form 4G/ 4A: Prepared By: O. Hibbert

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 21

Introduction To

Programming and
Problem Solving

Form 4G\
4A

Prepared By: O. Hibbert


Solving a problem on a
computer involves the following
activities:
1. Define the problem
2. Analyze the problem.
3. Develop an algorithm (a method) for solving
the problem.
4. Write the computer program corresponding
to the algorithm.
5. Test and debug the program.
6. Document the program. (explanation of how the
program works and how to use it.)
Algorithm Design
1. An algorithm is a set of instructions, which, if
accurately followed, will produce a solution to a
given problem. When an instruction is followed, we
say it is executed.

2. There are many different methods used for writing


algorithms.

3. Examples of algorithms are: flowcharts, pseudocode,


design structures, top down design approach, bottom
up design approach, etc.
(We will focus on Flowchart and Pseudocode. )
Computer instructions fall into
three main categories
1. Input instructions, used for supplying data to a
program inside the computer.

1. Processing instructions, used for manipulating data


inside the computer. These instructions allow us to
+,-,X , ÷, compare two values, and act according to
the result of the comparison. Also, we can move data
from one part of the memory to another. (assign)

1. Output instructions, used for getting information out


of the computer.
Categories of Programming
• A program is a sequence of instructions to the
computer

• The instructions are written in programming language

• Programmers write instructions in various


programming languages, some directly
understandable by the computer and others that
require intermediate translation steps.
Categories of
Programming cont…
Programming languages fall into the following
categories:

1. Machine Language
2. Assembly Language
3. High Level Languages
4. Fourth Generation Languages
5. Fifth Generation Languages
6. Natural Languages
Machine Language
1. consist of strings made up of 1s and 0s. The only programming
language the computer can understand. (it is understood by the
computer without any interpretation.)

2. All programs written in the other languages have to be translated to


machine languages before the computer can carry out the instructions.
Advantages
1. Fast execution speed
2. Efficient use of main memory.

Disadvantages
1. Writing of machine language is tedious and time consuming. Why is
this so?
2. Programming errors are difficult to find and correct (‘debug’)
Assembly Language
• is classified, as a low level language because detailed
knowledge of hardware specifics is still required.
• uses special code called mnemonic to represent
machine language instructions. e.g., instead of using
of 1s and 0s to represent an addition operation, a
programmer might use the mnemonic AD.

• before a computer can use an assembly language, it


must be translated into a machine language. This
conversion is made with a language translator
program called an assembler.

• Remember Machine Language is the only language


the computer can understand.
High Level Languages
• closely resemble human language and mathematical
notations.

• must be translated to machine language format.

• high level language is called the SOURCE CODE while


the translation version is called the OBJECT CODE.

• Two types of translator programs are available to


translate the high level language code to machine code,
COMPILERS and INTERPRETERS.
Compilers
1. translate the entire source code (all statement) to its
object code before execution takes place. A permanent
object program is generated. Whenever changes are
made to the source code the program has to be re-
compiled for the changes to take effect.

Interpreters
2. translate high-level statements one at a time, executing
each step immediately after it has been translated. No
permanent object program is generated. Each time a
source program is encountered, it is re-interpreted
Relationship between
source code, translator and
object code
SOURCE TRANSLATORS OBJECT
CODE CODE
Advantages of High Level Language
Over Machine Language

1.easier to learn and code programs in high level


languages since programmer does not need
detailed knowledge of the computer or its
internal operation

2.Errors are easier to avoid and detect

3.Many high level languages are machine


independent, making them portable
Disadvantage of high Level
languages over Machine Languages

 Execution of instructions is slower.

Can you think of any other?


Fourth Generation Languages
• requires much less effort in creating programs that high
level languages.
The objectives include:
• increasing the speed of program development
• minimizing end-user effort to obtain information from a
computer
• decreasing the skill level required of end users, so they
can concentrate on an application rather than on the
intricacies of coding. They can therefore solve their
own problems without the aid of professional
programmers.
• minimizing maintenance by reducing errors and making
programs easy to change
Fifth Generation Languages

 (5GL) is one that provides a visual or graphical


interface for creating the source code
(programming code).

 often converts the source code to machine


language using a 3GL or a 4GL complier.

 Object-oriented and web development tools


sometimes use a 5GL. For example visual basic
Natural Languages
• making computer language as close to human as
possible.

• E.g. a user enters the command “Get me sales figures


for January 1992”, a computer understanding natural
languages could interpret this and supply the desired
information.

• They enable users to communicate with computers in


their native language (English, French, etc.)
• Please read Chapters 16, 17
and 28 from class text.

• A copy of this presentation


will be sent to group’s site.

• Have a Great day. Happy


Coding

• Please Answer the following


questions. Due Next Class
PAST PAPER QUESTIONS
 (1995)
 (9a) Define the following
 Source code
 Object code
 Compiler

 (9b) Draw a labeled diagram to illustrate the


relationship between source code, object
code and compiler.
Past Paper Questions
 1997
 (9a) Explain the difference between
high level programming language and
machine level language.

 (9b) Explain the difference between an


interpreter and a compiler.
pseudocode
 An imitation computer program written
using mathematical notations and
English like statements to describe the
logics to solve a problem or carry out a
procedure.

GO BACK
mnemonic
 A word or string which is intended to be
easier to remember than the thing it
stands for. Most often used in
"instruction mnemonic" which are so
called because they are easier to
remember than the binary patterns they
stand for. characters also have
mnemonics like NAK, ESC, DEL intended
to evoke their meaning on certain
systems.
GO BACK

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy