[go: up one dir, main page]

0% found this document useful (0 votes)
24 views31 pages

Lec 1 Overview of Computer Systems

Uploaded by

dennismwenda342
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views31 pages

Lec 1 Overview of Computer Systems

Uploaded by

dennismwenda342
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Lecture 1

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

Hard Disk Drive (HDD) DVD/CD

Main Memory

CPU Monitor
Keyboard
Program Execution 4

 von Neumann architecture

Main Memory
loading
Program Program
(Instruction + Data)

Instruction result Instruction, data fetch

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

 All software must be written using a programming language


Computer Programming

 Programming Problem: - A task that requires a


program to be written
 Programming language: - It is a program with a
special role i.e. it enables us to come up with
other programs. It has instructions that enable us
to write programs
 It has features of a language
 Vocabulary
 Grammar: SYNTAX
 Interpretation/ meaning: SEMANTICS
Programming Language 7

 Language for programming computer processing


 Machine readable language designed to express computations that
can be performed by a computer
 Specify behavior of machine, express algorithms
 Human-Computer Communications
 Computer Languages have evolved from Machine languages to
natural languages
Software Development
Process
 Requirement analysis
 Design
 Implementation
 Testing
 Maintenance
Programming and 9

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

A Compiler is used to compile an entire An interpreter is used to translate each l


program and an executable program is ine of the program code immediately a
generated through the object program s it is entered

The executable program is stored in a An interpreter is used to translate each l


disk for future use or to run it in another ine of the program code immediately a
computer s it is entered

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.

 We will examine each of these.


ALGORITHMS…
 Flowcharts
 They are visual representation of algorithms
 Typically show a program’s logic.
 Can be instantiated using any programming
language we want i.e. flow charts are
language independent
 Flow charts are also easy for non-
programmers to understand.
ALGORITHMS…
 Flowchart Symbols
 Each symbol contains information on
what must be done at that particular
point.
 The arrow shows the order in which the
instructions must be executed
ALGORITHMS…
 Start/Stop

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

You might also like