1
VISUAL
PROGRAMMING
(CSC1243)
CHAPTER 1 –
UNDERSTANDING THE
CONCEPT OF COMPUTER
PROGRAMMING
CHAPTER 1 – Understanding the concept of 2
computer programming
1.0 Understanding the concept of computer programming
1.1 Program and Programming Language
1.2 Levels and Generations of Programming Languages
1.3 Program Development Life Cycle
1.4 Problem solving and algorithm design
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
3
Course Learning AT THE END OF THIS CHAPTER, YOU
Outcome SHOULD BE ABLE TO:
DESCRIBE THE CONCEPT OF COMPUTER
PROGRAMMING
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
4
INTRODUCTION
Computers can be found anywhere from the size of a desktop to
smaller than the palm of one’s hand such as desktop computers,
notebooks, netbooks, tablet PCs and mobile devices.
Many kinds of applications or apps can be downloaded into the
tablet or smartphone.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
5
INTRODUCTION (CONT.)
There are many ways to develop these applications.
Some websites provide templates to create apps quickly.
Users with programming knowledge can create their apps from scratch.
Examples of systems/apps developed using programming language:
Automated Teller Machine (ATM) systems,
Student Information Systems
Online Ticketing Systems
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
6
COMPUTER COMPONENTS
Computers are electronic devices capable of performing computations
and making logical decisions at speeds faster than human beings.
Hardware Software
Computer Components
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
LANGUAGE OF 12/5/2022
A COMPUTER
Computers can only
understand machine
language.
Machine language is
also called binary
numbers or binary code,
which is a sequence of
0s and 1s.
The digits 0 and 1 are
called binary digits or
bits.
A sequence of 8 bits is
called a byte.
7
VISUAL PROGRAMMING (Session : 2 2022/2023)
8
1.1 PROGRAMS AND
PROGRAMMING
LANGUAGES
9
DEFINITION OF COMPUTER
A computer is an electronic device, with its own memory,
capable of performing computations and making logical
decisions at speeds faster than human beings.
A computer can also be defined as a device which receives
information (Input) and manipulates it (process) to produce
results (output) based on a program or sequence of instructions.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
10
CATEGORIES OF COMPUTERS
MOBILE COMPUTERS
Mobile computers are computers which have mobility features such as
being small and capable of being handheld.
MICROCOMPUTERS
Microcomputers also known as personal computers, are widely used and
fast-growing. This type of computer can be used by individuals at home or
office.
SERVERS
Servers are more powerful compared to mobile and personal computers.
This is because servers able to control all the other devices within a network.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
11
CATEGORIES OF COMPUTERS (cont)
MAINFRAMES
Mainframes are larger and more expensive than the server. It needs to be kept in special wired,
air-conditioned rooms. Normally, mainframes are used in certain organizations to store and
process large amounts of data and transactions internally.
SUPERCOMPUTERS
Supercomputer is the largest, fastest and most expensive device. Since a supercomputer is a
high-capacity computer, it is used in very large organizations that need high processing power.
EMBEDDED COMPUTERS
Embedded computer can be found in electronic devices such as washing machines, televisions
and microwaves, and in computer devices such as smartphones and smartwatches, and even in
vehicles such as in the anti-lock braking system and the built-in navigation system.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
12
BASIC OPERATIONS OF A COMPUTER
INPUT
PROCESS
OUTPUT
STORAGE
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
13
COMPUTER SYSTEM
HARDWARE
The electric, electronic and mechanical equipment that makes
up a computer.
SOFTWARE
The series of instructions that tell the computer hardware how to
perform tasks.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
14
WHAT IS A PROGRAM?
Computers can only follow instructions.
A computer program is a set of instructions on how to solve a problem or
perform a task.
In order for a computer to compute someone’s gross pay, we must tell it to
perform the steps on the following slide.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
15
EXAMPLE : COMPUTING GROSS PAY
This well-defined, ordered set of steps for solving a problem is called an 12/5/2022
algorithm.
VISUAL PROGRAMMING (Session : 2 2022/2023)
16
PROGRAMMING LANGUAGES
The steps in an algorithm must be stated in a form the computer
understands
The CPU processes a series of 1’s and 0’s called machine language
instructions
This is a tedious and difficult format for people
Programming languages allow us to use words instead of numbers
Special software called a compiler converts the programming language
statements to machine language instructions.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
DIFFERENCES BETWEEN 17
PROGRAMS AND PROGRAMMING
A program is a set of instructions that tell the computer how to solve a problem or
perform a task.
Programming is the process of designing and writing computer programs.
A program is like a recipe. It contains a list of ingredients (variables) and a list of
directions (statements) that tell the computer what to do with the variables.
Computer programs guide the computer through orderly sets of actions specified
by the computer programmers.
The programmer must decide what the programs need to do, develop the logic of
how to do it and write instructions for the computer in a programming language
that the computer can translate into its own language and execute.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
THE IMPORTANCE OF COMPUTER 18
PROGRAMMING
Able to perform difficult tasks without making human-type errors such as
lack of focus, energy, attention or memory.
Capable of performing extended tasks at greater serial speeds than
conscious human thoughts.
Human brain cannot be duplicated or ‘re-booted’ like computers and
has already achieved ‘optimization’ through design by evolution, making
it difficult to upgrade.
Human brain does not physically integrate well, externally or internally
with current hardware and software.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
1.2 LEVELS AND GENERATIONS OF
PROGRAMMING LANGUAGES
19
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
LEVELS OF PROGRAMMING 20
LANGUAGES
12/5/2022
A programming language can be defined as –
“The language used for expressing a set of
instructions that can be executed by the
computer”.
Programming languages can be divided into
two major categories: low level and high-level
languages.
Low level languages can be further divided into
machine and assembly languages.
The high-level languages can be, however,
categorized into many types, such as Procedure
oriented, object oriented and problem oriented.
VISUAL PROGRAMMING (Session : 2 2022/2023)
LEVELS OF PROGRAMMING LANGUAGES 21
PROGRAMMING LANGUAGE
Low Level Language High Level Language
Machine Assembly •Pascal •Java •ASP
Language Language •COBOL •JavaScript •Perl
•C, C++ •Ruby •Python
•BASIC •PHP •CSS
Machine Language Assembly Language Java Language CSS Language
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
LEVELS OF PROGRAMMING LANGUAGES 22
LOW LEVEL LANGUAGE
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
LEVELS OF PROGRAMMING LANGUAGES 23
MACHINE LANGUAGE
The only language understood by computers Machine code:
is binary, also known as machine code.
Instructions for a computer to follow must
This is because computers are electronic therefore be written in machine code
devices that can only tell the difference
between the on and off states of an electric This was done by early computer
circuit. programmers
The numbers 1 and 0 are used by humans to Each sort of computer is different, so they
represent these on/off values. That’s why all need different binary instructions to
things written in binary look like this: perform the same task – different
0101001001000101010101100100100101010011 computers have different machine code
0100010100100001
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
LEVELS OF PROGRAMMING LANGUAGES 24
MACHINE LANGUAGE (CONT...)
Machine instruction is simply a string of binary digits. With a view to increase
readability, programmers assigned appropriate symbols to the op-codes on the
basis of the operation performed by the instructions. The symbols of a hypothetical
machine are given in Table.
Symbol (mnemonic) Binary code
Load 0000 0000
Add 0000 0001
Sub 0000 0010
: :
Stop 1111 1111
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
LEVELS OF PROGRAMMING LANGUAGES 25
ASSEMBLY LANGUAGE
To make it easier to program computers, a programming language was
invented.
It was called ‘Assembly‘ and was made up of a small set of command words
called mnemonics which programmers typed instead of binary Examples of
mnemonics are “MOV”, “ADD” and “PUSH”
Computers could not understand Assembly so it had to be converted to
machine code by an ‘assembler‘ before it could be run.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
LEVELS OF PROGRAMMING LANGUAGES 26
ASSEMBLY LANGUAGE CONT…
The most common assemblers for Assembly language programming 12/5/2022
development are:
Intel ASM
Microsoft MASM (MACRO Assembler).
Works on Microsoft Platforms (Windows and DOS).
Produces only .Com and .exe files.
Borland TASM (Turbo Assembler).
16-bit and 32-bit.
Supports all platforms.
VISUAL PROGRAMMING (Session : 2 2022/2023)
LEVELS OF PROGRAMMING LANGUAGES 27
WHY IS AL IMPORTANT TO LEARN?
Provides opportunity to know more about the operations of the PC.
Enable control of the PC – access to specific hardware features
Quicker, smaller and have larger capacities compared to other HL languages.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
LEVELS OF PROGRAMMING LANGUAGES 28
EXAMPLE:
12/5/2022
0100 MOV AX, 0123 →Move value 0123H to AX
0103 ADD AX, 0025 → Add value 0025H to AX
0106 MOV BX, AX → Move contents of AX to BX
0108 ADD BX, AX → Add contents of AX to BX
010A MOV CX, BX → Move contents of BX to CX
010C SUB CX, AX → Subtract contents of AX from CX
010E SUB AX, AX → Subtract AX from AX (clear AX)
0110 JMP 100 → Go back to the start
VISUAL PROGRAMMING (Session : 2 2022/2023)
29
COMPILERS INTERPRETERS
Translators:
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
Generations of Programming 30
Languages
Since the beginning of computers, programming languages have evolved from
unstructured, difficult-to-read languages to object oriented, easy-to-read
programming languages. The programming languages can be classified into five
generations of programming languages.
First generation Languages (1GL)
Second generation Languages(2GL)
Third generation Languages (3GL)
Fourth generation Languages (4GL)
Fifth generation languages (5GL)
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
GENERATIONS OF PROGRAMMING 31
LANGUAGES
First generation Languages (1GL)
Machine language - 0110 0011 1000
Example machine instruction: 11010111 10011011
Since it is a machine language, no translation is required and the program runs very fast and efficiently on
the machine
Second generation Languages(2GL)
The machine language comprising 0s and 1s is termed a 1st generation computer language. It is a machine-
dependent language. → Assembly language
Example machine instruction: 11010111 10011011
Third generation Languages (3GL)
These languages are also called high-level languages
Examples of 3GL are: ‘C’, ‘C++’, Java, Python, etc
Fourth generation Languages (4GL)
4GL offer non-procedural constructs such as ‘sort’, ‘index’, ‘search’, ‘create table’ etc
Examples of 4GL are: FoxPro, SQL, MATLAB, Oracle Reports etc
Fifth generation languages (5GL)
have been designed to develop machines that behave like humans.
The machines are also called artificially intelligent machines which is a branch of computer science concerned
with making computers behave like humans.
Examples of 5GL are: LISP and Prolog. 12/5/2022
VISUAL PROGRAMMING (Session : 2 2022/2023)
The timeline of the development of some popular programming languages
Language Remarks 32
Assembly Low level languages
1950-56 languages
1957 FORTRAN High level language for Sc. Applications
1958 ALGOL Algorithmic language supporting block
structures
1960 COBOL, LISP Business programming and List processing
1962 Simula
Simulation programming, first OOP language
1964 BASIC General purpose, easy to program language
1970
PROLOG, Logic programming language suitable for AI
Hope applications
Hope was a functional programming
1972 ‘C’ language
1973 PASCAL High level language suitable for system
programming
VISUAL PROGRAMMING (Session : 2 2022/2023) Block structured language
12/5/2022
The timeline of the development of some popular programming languages
Language Remarks 33
1983 Smalltalk, Ada OOP languages
1984 ML Functional programming
1986 C++, Eiffel OOP languages
1990 Haskell Functional programming
1990-1995 Perl, Python, JavaScript, Scripting languages
1995 PHP
2000 Java OOP language suitable for
2005-2006 Internet programming
C# A multi-paradigm
programming language
Ruby on Rails Web application framework
2010 (Standard) PHP Scripting language
2014 iOS/swift
Programming language for iOS
and OS X developers
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
1.3 Program Development
Life Cycle
34
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
Program Development 35
Life Cycle
The process of developing a program is called program development.
The process associated with creating successful application programs is
called the Program Development Life Cycle (PDLC).
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
36
Phase 1 : Analysis
First step in the Program Development Life Cycle (PDLC).
This process is done by reviewing the program specifications.
Other criteria must also be identified, especially the data that will be used
as input, the process involved and the output that will be produced.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
example 37
Calculate the sum of 3 integers 12/5/2022
Analysis:
1. To identify input, process and output
2. Input → 3 integers OR no1, no2, no3
3. Process → sum = no1 + no2 + no3
4. Output → sum
VISUAL PROGRAMMING (Session : 2 2022/2023)
38
Phase 2 : Design
A programmer needs to develop a series of steps with logical order, which
when applied would produce the output of the problem.
A solution is created using a structured programming technique known as
algorithm, which consists of pseudocode and flowchart.
A procedure or formula for solving a problem.
A step-by-step problem-solving process where the result is attained in a
limited amount of time.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
39
Phase 2 : Design (cont.)
Some requirements must be satisfied when creating an algorithm:
1. Unambiguousness
2. Generality
3. Correctness
4. Finiteness
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
40
Phase 2 : Design (cont.)
Before an algorithm is created, the three types of control structure should
be understood first.
A control structure is a pattern to control the flow of a program module.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
41
Pseudocode
A semiformal, English-like language with a limited vocabulary used to design and
describe algorithms.
Every statement in pseudocode involves keywords which define the process and
operands.
Each pseudocode statement should be written in a separate line.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
42
Pseudocode (cont.)
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
43
Pseudocode (cont.)
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
How to identify leap year 44
Pseudocode 12/5/2022
1.0 START
2.0 DECLARE int year
3.0 READ year
4.0 if year % 4 == 0
4.1 display “Leap Year”
5.0 else
5.1 display “Non-Leap Year”
6.0 END
VISUAL PROGRAMMING (Session : 2 2022/2023)
10 / 2 = 5 Balance 0 45
10 % 2 = 0
12/5/2022
10 / 3 = 3 Balance 1
10 % 3 = 1
10 / 4 = 2 Balance 2
10 % 4 = 2
6 / 6 = 1 Balance 0
6%6=0
VISUAL PROGRAMMING (Session : 2 2022/2023)
46
Flowchart
A graphic presentation of the detailed logical sequence of steps needed to
solve programming problems.
Uses geometric symbols where different symbols are used to represent different
actions such as start/stop, decision, input/output, processing and looping.
Similar to pseudocode, keywords are written in uppercase, while variable and
constant names as well as operations for the statements are written in lower case.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
Flowchart (cont.) 47
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
Flowchart (cont.) 48
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
Flowchart (cont.) 49
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
Flowchart (cont.) 50
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022