Programming Handout 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Western Educational Centre

Information Technology
Programming Handout

A computer program is a collection of instructions that performs a specific task when


executed by a computer. Most computer devices require programs to function properly.

A computer program is usually written by a computer programmer in a programming


language. From the program in its human-readable form of source code, a compiler or
assembler can derive machine code—a form consisting of instructions that the computer can
directly execute. Alternatively, a computer program may be executed with the aid of an
interpreter.

Computer programming languages are classified into two categories namely, high-level
languages and low-level languages. The most fundamental difference between the two is
that low-level languages are closer to the system hardware and require the knowledge of
hardware to write the instructions; whereas high-level programming languages are the
machine independent languages that do not require the hardware knowledge to write
instructions.

A High-Level Language is a computer programming language that uses English like


statements to write the computer instructions. High-level languages are most widely
programming languages because they are easy to understand to human being.

Here is a list of some important characteristics of high-level languages −

 It can be easily interpreted as well as compiled in comparison to low-level language.


 It can be considered as a programmer-friendly language.
 It is easy to understand.
 It is easy to debug.
 It is simple in terms of maintenance.
 It requires a compiler/interpreter to be translated into machine code.
 It can be run on different platforms.
 It can be ported from one location to another.
 It is less memory efficient, i.e., it consumes more memory in comparison to low-level
languages.
 Examples of high-level languages include C, C++, Java, and Python.
 It is widely used.
A Low-Level Language is also a category of computer programming language in which the
computer codes are written in the binary language or machine codes. Because of this, low-
level language is sometimes also known as machine language. The low-level language is
less friendly for human (programmer), but more friendly for machine because the computer
processor can directly process the codes written in the low-level language.

The following are the important characteristics of a low-level language −

 It can be understood easily by the machine.


 It is considered as a machine-friendly language.
 It is difficult to understand.
 It is difficult to debug.
 Its maintenance is also complex.
 It is not portable.
 It depends on the machine; hence it can't be run on different platforms.
 It requires an assembler that would translate instructions.
 It is not used widely in today's times.
Program testing is the process of executing a program with the intent of finding errors.

Debugging is the process of finding and resolving defects or problems within a computer
program that prevent correct operation of computer software or a system.

When the computer is interpreting or compiling a program that is your source code, an error,
whether major or minor will cause it to either produce (output) results or not reach the stage
of output at all. There are different types of errors which will cause your program to ‘crash’.

Logic errors
Logic errors occur when the programmer makes mistakes in the sequence of the program
statements such using the wrong formula or function ( ie using a MOD instead of SQR
FUNCTION). The program will usually compile that the compiler converts the source code
to object code. NOTE: that compilation with logic errors does not generate any syntax errors
or any warning messages but when the program is run it produces the wrong results.

Syntax errors
Syntax errors occur when a mistake is made in the programming language rules or violating
the rules governing the structure of the language. In short a syntax error occurs when the
programmer fails to follow the rules of the programming language exactly. For example if a
keyword such as input or print is spelt incorrectly or an endif was left out.

Run-time errors or execution errors


Run-time errors occur as the program compiles or runs. These errors are usually due to
unexpected events such as division by zero or lack of memory for the computer to
manipulate the data or a loop with no end. Run-time errors can be very difficult to trace as
the program may produce results most of the time.

Program documentation includes hard-copy or electronic manuals that enable users, program
developers, and operators to interact successful with a program. User documentation
normally consists of a user's manual. This manual may provide instructions for running the
program. A description of software commands, several useful examples of applications, and
troubleshooting guide to help with difficulties.
Sample Pascal Program
Write a pascal program that prompts the user to enter three numbers. Reads the three
numbers calculate and print their sum.

Program Numbers;

{Date Written: February 9, 2024}


{Author: Irwin High}
{Purpose: This program prompts the user for three numbers, reads the three numbers, calculate and print
their sum.}

Var
Num1, Num2, Num3, Sum: Integer;

Begin
Write(‘Please enter a number’);
Readln(Num1);

Write(‘Please enter a second number’);


Readln(Num2);

Write(‘Please enter a third number’);


Readln(Num3);

Sum:= Num1+Num2+Num3;
Write (Sum);
End.

You might also like