Programming Fundamentals Chapter 1 INTRO
Programming Fundamentals Chapter 1 INTRO
Programming Fundamentals Chapter 1 INTRO
Programming Fundamentals 1
Chapter 1
Hardware and software
Programming Languages
Problem solution and software development
Algorithms
Programming Fundamentals 2
Computer Hardware
Input unit
Output unit
Memory unit
ALU
CPU
Secondary storage
Programming Fundamentals 3
Input Unit and Output Unit
Input Unit
- It obtains information from various input devices and
places this information at the disposal of the other units.
- Examples of input devices: keyboards, mouse devices.
Output Unit
- It takes information that has been processed by the
computer and places it on various output devices.
- Most output from computer is displayed on screens, printed
on paper, or used to control other devices.
Programming Fundamentals 4
Memory Unit
Programming Fundamentals 5
ALU and CPU
CPU
The unit supervises the overall operation of the
computer.
Programming Fundamentals 6
Secondary Storage
Programming Fundamentals 7
Some terminology
Programming Fundamentals 8
Machine languages
Example:
00101010 000000000001 000000000010
10011001 000000000010 000000000011
Programming Fundamentals 9
Machine languages (cont.)
Programming Fundamentals 10
Assembly languages
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
Programming Fundamentals 11
Assembler
Translation
Assembly Machine
program
language language
(assembler)
program program
Programming Fundamentals 12
High-level Programming Languages
Programming Fundamentals 13
High-level Programming Languages (cont.)
Programming Fundamentals 14
Application and System Software
Two types of computer programs are: application
software and system software.
Programming Fundamentals 15
Examples of system software
Programming Fundamentals 16
PROGRAMMING LANGUAGES
What is Syntax?
Programming Fundamentals 17
The C Programming Language
In the 1970s, at Bell Laboratories, Dennis Ritchie and Brian
Kernighan designed the C programming language.
Programming Fundamentals 18
The C++ Programming Language
In 1985, at Bell Laboratories, Bjarne Stroutrup created C++
based on the C language. C++ is an extension of C that adds
object-oriented programming capabilities.
Programming Fundamentals 19
Structured Programming
During 1960s, many large softwares encountered severe
difficulties. Software schedules were late, costs exceeded
budgets and finished products were unreliable.
People realized that software development was a far more
complex activity than they had imagined.
Research activity in the 1960s Structured Programming.
It is a discipline approach to writing programs that are clearer
than unstructured programs, easier to test and debug and
easier to modify.
Chapter 5 discusses the principles of structured programming.
Pascal (Niklaus Wirth) in 1971.
Pascal was designed for teaching structured programming in
Programming Fundamentals 20
Object Oriented Programming
Programming Fundamentals 21
Object Oriented Programming (cont.)
Programming Fundamentals 22
PROBLEM SOLUTION AND SOFTWARE
DEVELOPMENT
Software development consists of three overlapping
phases
Programming Fundamentals 23
Phase I: Development and Design
The first phase consists of four steps:
1. Analyse the problem
Analyse the problem requirements to understand what the program
must do, what outputs are required and what inputs are needed.
2. Develop a Solution
We develop an algorithm to solve the problem.
Algorithm is a sequence of steps that describes how the data are to
be processed to produce the desired outputs.
Programming Fundamentals 24
Phase II: Documentation
- Program description
- Algorithm development and changes
- Well-commented program listing
- Sample test runs
- User’s manual
Programming Fundamentals 25
Phase III: Maintenance
Programming Fundamentals 26
ALGORITHMS
Programming Fundamentals 27
Flowchart symbols
Terminal
Input/output
Process
Flowlines
Decision
Programming Fundamentals 28
Example
Start
Input Name,
Hours, Rate
Dislay
Name, Pay
End
Programming Fundamentals 29
Algorithms in pseudo-code
Example:
Programming Fundamentals 30
Loops Note:
1. Loop is a very important
Start
concept in programming.
NUM 4 2. NUM NUM + 1 means
old value of NUM + 1
SQNUM NUM2
becomes new value of NUM.
The algorithm can be described
Print
in pseudocode as follows:
NUM 4
NUM, SQNUM
NUM NUM + 1 do
No SQNUM NUM2
NUM> 9?
Print NUM, SQNUM
NUM NUM + 1
Yes
Programming Fundamentals 31