Lec 1 Overview of Computer Systems
Lec 1 Overview of Computer Systems
Computer System,
Programming and Program
Design
Computer system
definition
a programmable machine that
Receives input
Stores and manipulates data
Provides output in a useful format
Computer System 3
Computer System
Hardware + Software
Computer Hardware
Main Memory
CPU Monitor
Keyboard
Program Execution 4
Main Memory
loading
Program Program
(Instruction + Data)
CPU PC
Software 5
system software
Efficient management of computer system and resources
Operating System, compiler, debugger
application software
All kinds of software other than system software
Wordprocessor, spreadsheet(excel), graphics SW, artificial
intelligence SW, Game SW, Statistics SW, medical SW
Execution
Programming Tool
Editor, Compiler, Interpreter, Debugger, and etc
Integrated Development Environment (IDE)
Program Edit
Error
Error
Compile
Execution
Error 10
compile-time error
Error occurring during compilation
Grammar check
Cannot execute if there is compile error
logical error
Grammar is OK but logical error
run-time error
Abnormal termination owing to unexpected reasons
during program execution
Ex) divided by zero, illegal memory access
Debugging 11
debugging
Bug : program error
Debugging : bug correction
Difference Between
Compiler & Interpreter
COMPILER INTERPRETER
The compiled programs run faster The Interpreted programs run slower
Most of the Languages use compiler The Interpreted programs run slower
Lecture 1.2
ALGORITHMS
Introduction
A computer program is a sequence of
instructions written to perform a specified
task for a computer.
Programming is the process of writing,
testing, debugging/troubleshooting, and
maintaining the source code of computer
programs. It is all about problem solving.
Programming methodology deals with the
analysis, design and implementation of
programs.
ALGORITHMS
An algorithm is the series of steps that are used to
solve a programming problem.
It may also be considered as a plan for solving a
programming problem that specifies the sequence of
steps used in the solution.
The following are mandatory features that an
algorithm must have:
(I) An algorithm must have a start and an end
point.
(II) Every step must be doable or performable:-
(A) using a finite amount of resources
(B) in a finite amount of time.
Properties of a Good
Algorithm
Precision – the steps are precisely stated (defined).
Uniqueness – results of each step are uniquely
defined and only depend on the input and the
result of the preceding steps.
Finiteness – the algorithm stops after a finite number
of instructions are executed.
Input – the algorithm receives input.
Output – the algorithm produces output.
Generality – the algorithm applies to a set of inputs.
ALGORITHMS…
In summary an algorithm will consist of a
series of steps solving a problem.
There must be a starting point and an ending
point and each step is something the
computer can do and finish.
So the format of an algorithm is: start, step1,
step2, … , stepn, stop.
Generally the steps are numbered or labeled
from start to stop.
Formulation of algorithms is a major step in
writing computer programs.
ALGORITHMS…
The most common means of
representing algorithms is by the use of
flowcharts
pseudo code.
Start
Stop
Input/ Output
Read Write
ALGORITHMS…
Flow Chart Symbols …
Process box
Use not more than two statements in
each box.
Sum:= Sum + 1;
Count:= Count + 1;
ALGORITHMS…
Flow Chart Symbols …
Decision/selection box
Based on the value of the decision
parameter, follow one of the two
available paths
ALGORITHMS…
PSEUDO CODE
Pseudo codes are mixture of English
statements and terms that are used in
programming. The programming terms
may include:
START, BEGIN, END, STOP, IF, THEN,
WHILE, DOWHILE, ENDWHILE,
REPEAT, FOR, UNTIL, DISPLAY,
WRITE, READ, etc.
ALGORITHMS…
Programming Constructs
Programming constructs are the building
blocks of a program. There are three
programming constructs.
These are sequence, repetition, and
selection. These are considered below:-
ALGORITHMS…
Sequence
Start:
process A;
process B;
Process
Stop:
ALGORITHMS…
Repetition
These are steps that must be performed more
than once.
DO WHILE
Start:
DO:
Process;
WHILE( condition)
ALGORITHMS…
Decision/ Selection
IF condition holds
THEN perform Process
IF condition THEN
…. ELSE …
ALGORITHMS...
An Algorithm That Reads & Displays A Set Of 6
Numbers
Planning
Track the number of times reading is done by
setting up a counter.
When 6 numbers have been read, stop.
Algorithm Description
1. Start
2. Setup variables: Number, Count
3. Initialize variables: Number:=0; Count:=0;
4. Read a Number
5. Display the Number
6. Increase Count by 1
7. If Count<=6 Repeat from 4
8. Stop
ALGORITHMS...
An Algorithm That Reads & Displays A Set
Of 6 Numbers (Using DO WHILE
repetition construct)
○ Pseudocode
○ START
○ Variables: Number, Count
○ Number:=0;
○ Count:=0;
○ DO
READ Number;
DISPLAY Number;
Count:=Count+1; //increase count by
1
○ WHILE Count<=6;
○ STOP
An
Algorithm
That Reads
& Displays A
Set Of 6
Numbers
Flow Chart