0% found this document useful (0 votes)
3 views4 pages

Programming Languages

The document provides an overview of programming languages, distinguishing between low-level and high-level languages, and outlines the generations of programming languages from machine code to fifth generation languages used in artificial intelligence. It details the five stages of program implementation, including creating source code, compiling, linking, testing, and maintaining programs, as well as the types of errors that can occur during programming. Additionally, it discusses the processes of testing and debugging, highlighting various methods for identifying and correcting errors in code.

Uploaded by

ddamekia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Programming Languages

The document provides an overview of programming languages, distinguishing between low-level and high-level languages, and outlines the generations of programming languages from machine code to fifth generation languages used in artificial intelligence. It details the five stages of program implementation, including creating source code, compiling, linking, testing, and maintaining programs, as well as the types of errors that can occur during programming. Additionally, it discusses the processes of testing and debugging, highlighting various methods for identifying and correcting errors in code.

Uploaded by

ddamekia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Information Technology

Grade 11
Introduction to Programming
SUB-TOPIC: PROGRAM IMPLEMENTATION

A programming language is a set of rules that provides a way of telling a computer what operations to perform.
There are two levels of programming language.

· Low level- a low level language is a machine dependent language whose source code is written in
machine code or assembly language

· High level language- this is a machine independent, problem oriented language whose source
code is written in statements that closely resemble English.

Key terms

Source code- this is the set of instructions and statements written by a programmer using a human-readable
programming language, usually as a plain text. This is what humans can read write and understand (high level
language)

Object Code- this is what some computer programs produce from source code into machine language.(binary)
(low level programming)

Executable code- This is the result of all the various object code modules together.

Generations of programming language

●​ First Generation Language: Machine Code

These are low level languages that can be understood by the computer so they do not need to be translated.
Binary is used to program in machine language. The programs execute quickly but it is difficult and time
consuming to write.

Example: 100 0001

100 0010
●​ Second Generation Language: Assembly Language

These are low level languages that use short pieces of code instead of binary. Each code looks and sounds like
the value or action it represents. An assembler is used to translate assembly language into machine code.

Example: ADD B, 20

This command instructs the computer to add the value 20 to accumulator B.

●​ Third Generation:

These are high level languages that use statements in English that are easy for programmers to use. Example of
popular third Generation languages:
-Pascal
-COBOL (Common Business Oriented Languages)
-FORTRAN(Formula Translation)
-BASIC (Beginner’s All purpose Symbolic Instruction Code)
-C

●​ Fourth Generation

They use English like statements that offer extra help through prompts, instructions and wizards. Wizards are
program assistants that guide the user. Examples:
SQL-(Structured Query Language)
Visual Basic
C++
Oracle report

●​ Fifth Generation

These are built on third and fourth generation languages and are sometimes called non-procedural languages.
They only require the programmer to write the goals that have to be achieved and any constraints or parameters
that are required. The computer solves the problem. It is used for artificial intelligence.

Example:
?-fruit apple- the first asks is an apple a fruit?
?-fruit (x)- the second asks what things are fruits
the computer could respond Yes …………………..X = apple

Five stages of Program implementation:


· Stage 1: Create the source code
This is when you write the program using a programming language. The code you write using a high
level language or assembly language is known as source code.

· Stage 2: Interpret and Compile

The computer DOES NOT understand high-level source code. It requires an INTERPRETER or
COMPILER to TRANSLATE the source code into object code.

Key words

Translators are systems software that convert code into a programming language that the computer can
process. Examples: Interpreters, Compilers and Assemblers

●​ Interpreters- this is a program that converts or translate a program into machine code one line at a time,
if an error is detected then translation is aborted
●​ Compilers- translate all program lines or code in one go and create a stand-alone program. Once
translation is complete the compiler instructs the processor to carry out that program. Compilers are
more efficient than interpreters because the code is compiled only once.
●​ Assembler- this is used to translate assembly language into machine code.

Stage 3: Link

When you write a long or complex program, you will probably write it in pieces or sections. Linking
puts the sections together to create one piece of code.

·Stage 4: Test and Execute

Before you run, or execute a program, you should test it on paper to see if it works properly.

· Stage 5: Maintain the program

Once you have a working program that fulfills its purpose, try to maintain it. Perhaps it needs some extra
features or could be restructured so it is easier to use. Go back to the program code and modify it. You
could add comments on how to use the program, as well as comments within the program on how it works.

TESTING AND DEBUGGING

Programs are tested to pick up errors. Errors can be detected when the program is being translated. There are
three kinds of errors:

· Syntax errors
· Logic Errors
· Run-time Errors

1.​ Syntax error


Syntax errors occur when a mistake is made in the language rules or sentence structure of the
programming language. Examples of syntax errors include misspelling of a variable or keyword. Syntax
errors stop the program instructions or source code being converted to machine code. Tools used with
the program usually detect syntax errors quite easily.
Example: red num2 (it should be read num2)
You have the variable Height_1 but in the program you write height 1

2.​ Logic errors


Logic errors occur when a programmer makes mistakes in the sequence of the program sentences, such
as using the wrong mathematical formula, wrong operator in an expression or incorrect use of looping
structures. Logic errors do not prevent the program from being compiled, however it will produce the
wrong results.
Example: You were asked to find the product of two numbers but you wrote
Product = Num1 + Num2 (obviously the wrong result will be printed as you have a plus arithmetic
operator instead of a multiplication arithmetic operator)

3.​ Runtime errors


Runtime errors occur as the program compiles or ‘runs’. These errors are usually due to unexpected
events such as division by zero (0) or lack of memory for the computer to manipulate the data. Runtime
errors can be very difficult to trace as the program may produce results most of the time.
Example total = num4 /0

TESTING AND DEBUGGING

Debugging is the process of finding the errors in the source code (detection), understanding why they
occurred (diagnosis) and correcting them. It is the process of fixing errors when you discover them.
Errors are often found through error messages generated by the program or because the program does
not behave as expected.

Testing is the act of looking for errors in a program. It is the process of locating the errors and defining
what will happen once these errors occurs

Types of testing
❏​ Dry run - this is a method of manual checking that a program does not contain any logic errors.
❏​ Trace tables- this is used to constantly check or trace the logic of a program or the value of a
variable in a loop.
❏​ Computer testing- testing the program on a computer by running it with as many different types
and combinations of data as possible.

You might also like