[Week 2 3 ] Lecture Note
[Week 2 3 ] Lecture Note
ng
1
Learning Objectives
Understand the categories of software and their
applications
Explore the generation of programming languages
To understand the steps involved in program
development
To understand the place of algorithms, flowcharts and
pseudo code in program development
2
What is Software?
It is a set of instructions that causes the hardware
to function in a desired way.
This set of instructions is often referred to as a
program
3
Types of Software
Computer software can be split into two major
categories:
– System software
– Application Software
4
Softwares
5
Role of Systems Software
6 6
Introduction
System software is
– The interface between the user and hardware
– The interface between application software and hardware
System software can be classified into three:
– Operating System
– Translators
– Utility programs
7
1. Operating System (OS)
It is the software that manages the resources of a
computer system and schedules its operations.
It acts as the interface between the hardware and other
user programs and facilitates the execution of programs
– UNIX
– MS-DOS
– Windows
8
2. Translators
Computer can understand instructions only when
they are written in their own language, i.e. machine
language.
Therefore a program written in any other language
should be translated into machine language
The software that translates the instructions of
different languages is known as translator
9
2. Translators (Cont’d)
There are two types of translators namely:
– Compilers
– Interpreters
10
2. Translators (Compiler)
A compiler checks the entire user – written program (known
as source program) and if it is error free, produces a complete
program in machine language (known as object program)
– The source program is retained for possible modifications and
corrections and the object program is loaded into the computer for
execution
If the source program contains errors, the compilers produce
a list of errors at the end of the execution of the program
11
2. Translators (Interpreter)
An interpreter does a similar job to the compiler but in a
different style
– The interpreter translates one statement at a time and if it is
error-free, executes.
Thus an interpreter translates and executes the first
instruction before it goes to the second, while a compiler
translates the whole program before execution
12
3. Utility Programs
Help to perform maintenance and correct problems
with a computer system. For example
– Hardware utilities
– Virus-detection and recovery utilities
– File-compression utilities
– Spam and pop-up blocker utilities
13
Application Softwares
14
Introduction
There are two types of application software
namely:
Application programs (proprietary or open source)
General purpose packages (off-the-shelf software)
15
1. Application Programs
• These are user written programs to do a specific job
which can be changed to meet the individual needs.
• These programs can be written in different languages
such as BASIC or C or by using database packages
like Oracle.
• Examples: Inventory management, Payroll, Billing,
Airline Reservation etc.
16
2. General Purpose Packages
• These packages are developed to suit the needs of research
workers/scientists in different fields.
• They can be categorized as follows:
• Data Analysis: SPSS
• Word Processing: MS-Word
• Spreadsheet and Accounting: MS-Excel, Sage
• Graphics & Presentation: MS-PowerPoint, Prezi, Corel Draw etc.
• Databases: Oracle
• Programming languages: Visual Basic, C/C++, Python, Java
17
Evolution and History of Programming
Languages
18
History Timeline
19
The Evolution of Programming Languages
20
First Generation Languages
Machine languages are the first generation
languages.
They consist of strings of numbers (i.e. 0s and 1s)
the computer’s hardware can use.
Different types of hardware use different machine
code
21
Second Generation Languages
Assembly languages can be regarded as the second-
generation languages
They are easier to work with than machine languages
To create programs in assembly language, developers use
cryptic English-like phrases to represent strings of numbers
– The code is then translated into object code, using a translator
called an assembler
22
Assembly
code
Assembler
Object code
23
Higher-Level Languages
24
Introduction
Higher-level languages are more powerful than
assembly language and allow the programmer to
work in a more English-like environment
They can be sub-divided into:
– Third-generation languages
– Fourth-generation languages
– Fifth-generation languages
25
Third Generation Languages
(3GLs)
They are the first to use true English-like phrasing
making them easier to use than previous languages
They are portable, meaning the object code created
for one type of system can be translated for use on a
different type of system
Examples include:
– FORTRAN, COBOL, Pascal, BASIC, C, C++, Java
26
Fourth Generation Languages
(4GLs)
These are easier to use than 3GLs.
4GLS may use a text-based environment (like a
3GL) or may allow the programmer to work in a
visual environment, using graphical tools.
Examples include:
– Visual Basic, Visual C++ etc.
27
Fifth Generation Languages
(5GLs)
These high-level languages use artificial
intelligence to create software.
They can be used to solve problems using
constraints rather than algorithms
Example includes:
– Prolog
28
Language Generations
29
Assignment
Find out other generations of
programming languages with examples
– Maximum of 1 Page
30
Program development
31
Why we develop programs?
Answer
– To solve problems
32
Steps involved in developing programs
34
Example 1
Assume that the gross pay of an employee is to be
calculated and then 10 percent of the gross is to be
removed as tax. The yield being the net pay.
Write down the algorithm for this problem.
35
Algorithm for Example 1
1. Begin
2. Input name, hours_worked, and wage per hour
3. Calculate gross_pay = hours_worked * wage per hour
Calculate tax = (10/100) * gross_pay
4. Calculate net_pay = gross_pay – tax
5. Print name, net_pay
6. End
36
Example 2
Write an algorithm to read the name and the mark
of one student then add 5 to his/her mark.
37
Algorithm for Example 2
1. Begin
2. Input name, mark
3. new_mark = mark+5
4. Print name, new_mark
5. End
38
Flowchart Basic Symbols
39 39
Flowchart for Example 1
Start
1. Begin
2. Input name, hours_worked, and Input name,
hours_worked,
wage per hour wage_per_hour
3. Calculate gross_pay =
hours_worked * wage per hour grosspay = hours_worked * wage_per_hour
tax = (10/100) * grosspay
Calculate tax = (10/100) * gross_pay net_pay = grosspay - tax
40
Flowchart for Example 2
Start
1. Begin
Input name, mark
2. Input name, mark
3. new_mark = mark+5
new_mark = mark + 5
4. Print name, new_mark
5. End Print name,
new_mark
End
41
Exercises
Given two numbers find the sum, product
and average. Design an algorithm and
flowchart to do this
Design an algorithm and flowchart to
convert temperature in Fahrenheit to
Celsius given the formula
– C = 5/9 * (F - 32)
42
VB Control Structures
43
Objectives
Working principles of various types of control
structures in VB
Syntax & semantics of various control statements
Implementation in Programming.
44
Control Flow
In a program, statements may be executed
sequentially, selectively or iteratively.
Every programming language provides constructs
to support sequence, selection or iteration. So
there are three types of programming constructs:
–Sequential Constructs
–Selection Constructs
–Iterative Constructs
45
1. Sequential Construct
The sequential construct means the statements are
being executed sequentially. This represents the default
flow of statements.
Statement 1
Statement 2
Statement 3
46
2. Selection Construct
The selection construct means the
execution of statement(s) depend True Statement 1
on the condition-test.
If the condition is true Condition
?
– Statement executes, program
continues to next statement
False Statement 2
If the condition is false
– Statement ignored, program
continues
47
Iterative Constructs
The iterative or repetitive False Condition
constructs means The exit condition
?
repetition of a set-of-
statements depending on True
a condition-test.
A set of statements are Statement 1 The loop
repeated till the condition body
or Boolean expression
Statement 2
evaluates to true.
This is also called Looping
48
Examples of Control Structure
• repetition control structures: • Selection control structures:
– While – If/Then
– Do While/Loop – If/Then/Else
– Do/Loop While – Select Case
– Do Until/Loop
– Do/Loop Until
– For/Next
– For Each/Next
49
Example 3
Write an algorithm to read the name and mark of
10 students and calculate the new mark of each by
adding 5 to mark.
50
Algorithm for Example 3
1. Begin
2. studentcount =1
3. Do
read name, mark
calculate new_mark = mark + 5
print name, new_mark
studentcount = studentcount +1
4. while studentcount <= 10
5. End
51
Flowchart for Example 3
Start
1. Begin studentcount = 1
Read name,
2. studentcount =1 mark
3. Do New_mark = mark + 5
52
Assignment
Write an algorithm and draw a flowchart to
read the name, CA score and exam score of 10
students and print the name, total score and
grade letter for each student. (Given that: 70-
100 is A; 60-69 is B; 50-59 is C; 45-49 is D and 45 and
below is F)
53