PPS - Unit 1
PPS - Unit 1
INTRODUCTION OF
COMPUTER SYSTEM AND
PROBLEM SOLVING
FYBTEC
H Subject : Programming and Problem Solving
Unit1Contents
2
Computer:
The word computer comes from the word “compute”, which means, “to
calculate”
Computer is an electronic device that can perform arithmetic and logical
operations at high speed
A computer is also called a data processor because it can store, process,
and retrieve data whenever desired
Data is raw material used as input and information is processed data
obtained as output of data processing
Architecture of Computer system
5
Generation of Computers
6
Note:
SSI: Small Scale Integration
MSI: Medium Scale Integration
PDP: Programmable Data Processors
CDC: Control Data Corporation
Generation of Computers
10
Note:
VLSI: Very Large Scale Integration VAX: Virtual Address Extension
Generation of Computers
11
Note:
ULSI: Ultra Large Scale Integration SGI: Silicon Graphics Inc.
PVM: Parallel Virtual Machine PARAM: Parallel Machine
Generation of Computers
12
1. According to Type
i. Digital Computer
A computer that performs calculations and logical
operations with quantities represented as digits,
usually in the binary number system
i. Micro computer
Desktop Computer: A personal or micro-mini computer
sufficient to fit on a desk
Laptop Computer: A portable computer complete with an
integrated screen and keyboard. It is generally smaller in size
than a desktop computer and larger than a notebook computer
Palmtop Computer/Digital Diary /Notebook /PDAs: A
hand-sized computer. Palmtops have no keyboard but the
screen serves both as an input and output device.
ii. Mini computer
A midsized computer. In size and power, minicomputers lie
between micro computer and mainframes.
iii. Mainframes
A very large and expensive computers capable of supporting
hundreds, or even thousands, of users simultaneously
Classification of Computer
16
3. According to Purpose
i. General Purpose
General purpose computers are
designed to perform a range of tasks
e.g. Personal Computer
A storage device is any computing hardware that is used for storing and
extracting data
It can hold and store information both temporarily and permanently, and can be
internal or external to a computer, server or any similar computing device
There are two main types of storage devices: Primary and Secondary
DRAM:
DRAM needs to be refreshed thousands of times per second
DRAM stores a bit of data using a transistor and capacitor pair, which together
comprise a memory cell
The capacitor holds a high or low charge (1 or 0, respectively), and the transistor acts
as a switch that lets the control circuitry on the chip read the capacitor's state of charge
or change it
As this form of memory is less expensive to produce than SRAM, it is the
predominant form of computer memory used in modern computers.
SRAM:
SRAM does not need to be refreshed, which makes it faster, but it is more expensive
than DRAM
In SRAM, a bit of data is stored using the state of a flip-flop
This form of RAM is more expensive to produce, but is generally faster and requires
less power than DRAM and, in modern computers, is often used as cache memory for
the CPU
Read Only Memory (ROM)
27
A PROM is a memory chip on which data can be written onto only once. Once a program
is written onto a PROM chip, it remains there forever
Unlike RAM, PROM retains its contents when the computer is turned off
The difference between a PROM and a ROM is that a PROM is manufactured as blank
memory and programmed later with a special device called PROM programmer or the
PROM burner, whereas the ROM is programmed during manufacturing process.
The process of programming a PROM is sometimes called burning a PROM
An EPROM is a special type of PROM that can be erased by exposing it to ultraviolet light
Once erased, it can be reprogrammed. An EPROM is similar to a PROM except that it
requires ultraviolet radiation to be erased
Types of ROM
29
Memory Storage
Devices
Magnetic Disks
Number System
34
Characteristics
Use symbols such as I for 1, II for 2, III for 3 etc
Each symbol represents the same value regardless of its position in the
number
The symbols are simply added to find out the value of a particular
number
Difficulty
It is difficult to perform arithmetic with such a number system
Positional Number System
36
Characteristics
Use only a few symbols called digits
These symbols represent different values depending on the position
they occupy in the number
The value of each digit is determined by:
1. The digit itself
2. The position of the digit in the number
3. The base of the number system (Base = total number of digits in the
number system)
The maximum value of a single digit is always equal to one less
than the value of the base
Binary Number System
37
Characteristics:
The maximum value of a single digit is 1 (one less than the value of the base)
Characteristics:
The maximum value of a single digit is 9 (one less than the value of the base)
Characteristics:
The maximum value of a single digit is 7 (one less than the value of the base)
Since there are only 8 digits, 3 bits (2 3 = 8) are sufficient to represent any octal
number in binary
Hexadecimal Number System
40
Characteristics:
Has total 16 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7,8, 9, A, B, C, D, E, F). Hence its base = 16
The symbols A, B, C, D, E and F represent the decimal values 10, 11, 12, 13, 14 and 15
respectively
The maximum value of a single digit is 15 (one less than the value of the base)
Since there are only 16 digits, 4 bits (2 4 = 16) are sufficient to represent any hexadecimal
number in binary
Conversions
41
Decimal to Binary
Here is an example of using repeated division to convert 1792
decimal to binary:
Decimal to Octal
Here is an example of using repeated division to convert 1792
decimal to octal:
Decimal to Hexadecimal
Here is an example of using repeated division to convert 1792
decimal to hexadecimal:
Step 1 − Divide the binary digits into groups of three (starting
from the right).
Step 2 − Convert each group of three binary digits to one
octal digit.
Example
Binary Number − 101012
Calculating Octal Equivalent −
Step Binary Number Octal Number
1. 101012 010 101
2. 101012 28 58
3. 101012 258
Binary Number − 101012 = Octal Number − 258
Conversion from Octal to Binary
47
Step 1 − Divide the binary digits into groups of four (starting
from the right).
Step 2 − Convert each group of four binary digits to one
hexadecimal symbol.
Example
Binary Number − 101012
Calculating Octal Equivalent −
Step Binary Number Hexadecimal Number
1. 101012 0001 0101
2. 101012 116 516
3. 101012 1516
Binary Number − 101012 = Hexadecimal Number − 1516
Conversion from Hexadecimal to binary
49
Drop any leading zeros or pad with leading zeros to get groups of four
binary digits (bits):
Binary 011100101 = 1110 0101
Decimal 8 4 2 1
00 0 0 0 0
01 0 0 0 1
02 0 0 1 0
03 0 0 1 1
04 0 1 0 0
05 0 1 0 1
06 0 1 1 0
07 0 1 1 1
08 1 0 0 0
09 1 0 0 1
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1
Hexadecimal to Octal
52
For example, a 3-bit memory location can hold one of these eight binary
patterns: 000, 001, 010, 011, 100, 101, 110, or 111
Hence, it can represent at most 8 distinct entities. You could use them to
represent:
Numbers 0 to 7
Characters 'A' to 'H‘
8 kinds of fruits like apple, orange, banana
or 8 kinds of animals like lion, tiger, etc.
Data Representation
54
Memory Units
Data Representation: Signed and Unsigned
55
Unsigned integers can represent zero and positive integers, but not negative
integers.
The value of an unsigned integer is interpreted as "the magnitude of its underlying
binary pattern".
Example 1: Example 2:
Suppose n=8 and Suppose n=16 and
binary pattern is 0 100 0001 B binary pattern is 0001 0000 0000 1000 B
Value of this unsigned integer is: Value of this unsigned integer is:
16 0 (2^16)-1 (=65,535)
32 0 (2^32)-1 (=4,294,967,295)
64 0 (2^64)-1 (=18,446,744,073,709,551,615)
The Most-significant Bit (MSB) is the sign bit, with value of 0 representing
positive integer and 1 representing negative integer.
The remaining n-1 bits represents the magnitude (absolute value) of the integer.
The absolute value of the integer is interpreted as "the magnitude of the (n-1)-
bit binary pattern".
Data Representation: Signed
59
Example 1: Example 2:
Example 3: Example 4:
1's complement
The 1's complement of a number is found by changing all 1's to 0's and
all 0's to 1’s.
Example of 1's Complement :
Complement of a number
62
2's complement
The 2's complement of binary number is obtained by adding 1 to the
Least Significant Bit (LSB) of 1's complement of the number.
2's complement = 1's complement + 1
2’s complement
Data Representation:
63
Floating point
In computers, floating-point numbers are represented in
scientific notation of fraction (F) and exponent (E) with a
radix of 2, in the form of F×2^E
Both E and F can be positive as well as negative
Modern computers adopt IEEE 754 standard for representing
floating-point numbers
There are two representation schemes:
32-bit single-precision
64-bit double-precision
Data Representation:
64
Floating point
32-bit Single-Precision Floating-Point Numbers
The most significant bit is the sign bit (S), with 0 for positive numbers and 1 for
negative numbers
The following 8 bits represent exponent (E)
The remaining 23 bits represents fraction (F) / Mantissa (M)
Data Representation:
65
Floating point
NORMALIS
BIASED
TYPES SIGN ED BIAS
EXPONENT
MANTISA
Single
1(31st bit) 8(30-23) 23(22-0) 127
precision
Double
1(63rd bit) 11(62-52) 52(51-0) 1023
precision
Examples of Single-Precision Floating-Point
Numbers
66
1010.0110000000000000000000
Data Representation:
67
Floating point
In 64-bit Double-Precision Floating-Point Numbers
The most significant bit is the sign bit (S), with 0 for positive numbers and 1 for
negative numbers
The following 11 bits represent exponent (E)
The remaining 52 bits represents fraction (F) / Mantissa (M)
Examples of Double-Precision Floating-Point
Numbers
68
Data Representation: char
69
e.g. the 8-bit pattern "0100 0010 B" could represent anything under the
sun known only to the person encoded it
In the ASCII character set, each binary value between 0 and 127
represents a specific character
Most computers extend the ASCII character set to use the full range of 256
characters available in a byte
ASCII
71
• Code numbers
• 65 to 90 represents 'A' to 'Z'
• 97 to 122 represents 'a' to 'z'
• 48 to 57 represents '0' to '9'
System software are designed to control the operation and extend the
processing capability of a computer system
e.g. Operating System, Compiler, Assembler, Linker, Loader
System Software are programs that are designed specifically for running the
hardware on a personal computer
This means that system software is designed to communicate with the internal
parts of your computer such as the hard drive, RAM, ROM, cache,
microprocessors, etc. so that the user doesn't have to.
System software is a collection of programs that supports computer operations.
System software can be separated into two different categories, Utility Programs
and Operating Systems
Utility programs perform a very specific task, to either enhance or manage your
computer, for example your virus protection program
Introduction to System Software
77
Introduction to System Software
78
Editor:
A program that enables you to create and edit text files
Text Editor is a simple application required for editing plain text such
as notepad.
Introduction to System Software
79
Compiler:
Assembler:
Linker:
In high level languages, some built in header files or libraries are stored
These libraries are predefined and these contain basic functions which
are essential for executing the program
These functions are linked to the libraries by a program called Linker
If linker does not find a library of a function then it informs to compiler
and then compiler generates an error
The compiler automatically invokes the linker as the last step in
compiling a program
Introduction to System Software
82
Loader:
Starting Point
Expected Outcome
Possible Procedure
How do We Solve Problems?
90
We need to THINK!
We need to engage in one or more of the following
types of thinking:
Logical reasoning
Mathematical reasoning
Lateral thinking
Problem solving is easier if we employ a problem
solving framework and an appropriate problem
solving strategy to aid us.
A Problem Solving Framework
91
To understand a problem
We need to read and reread it till we understand every
detail
We need to dissect the problem into its component
parts (e.g. problems and sub-problems)
We need to remove any ambiguity
Numerically?
Graphically?
Tabular data?
Natural language?
Does the problem lend itself to a particular problem
Carlos and his friends have a fantasy football league in which each team will play
each other three times. The teams are Medellin, Cali, Antigua, Leon, Juarez, Quito
and Lima. How many games will be played in all?
Imperative Programming
Follows the classic von Neumann-Eckert model
Functional Programming
Computing by applying functions to given parameters
Logic Programming
Rule-based (rules are specified in no particular order)
e.g. Prolog
What is Programming Language
112
◻ The language must allow the programmer to write simple, clear and
concise programs.
◻ It must be simple to use so that a programmer can learn it without
any explicit training.
◻ It must be platform independent. That is, the program developed
using the programming language can run on any computer system.
◻ The Graphical User Interface (GUI) of the language must be
attractive, user-friendly, and self-explanatory.
◻ The function library used in the language should be well
documented so that the necessary information about a function can
be obtained while developing application.
Characteristics of Programming Languages
(Cont…)
115
Alphabets/
Constants/
Digits/ Program
Variables/ Instructions
Special
Keywords
Symbols
Need to Study Programming Language
118
Else
If b>c
Display b is the largest number.
Else
Display c is the largest number.
Step 5:STOP
Generalized Algorithm
128
loop
By using sentinel value It is special value
132
As a flowchart
As a pseudocode
As a program
Program Planning Tools
133
Flowchart
Structure charts
Pseudo codes
Flowchart
134
Flowcharting Symbols:
There are 6 basic symbols commonly used in flowcharting of assembly
language programs: Terminal, Process, input/output, Decision, Connector
and Predefined Process
135
Flowchart
Pictorial representation of an algorithm
Steps of an algorithm are shown in different
START
Read A and B
C=A+B
Display C
STOP
Flowchart Examples
138
START
Read A and B
NO
Is
A>B
YES
Display A Display B
STOP
Draw flowchart to find the largest among three different
numbers entered by user.
139
Advantages and Limitations
140
Advantages:
Better Communication
Effective Coding
Systematic Debugging
Systematic Testing
Limitations:
Time consuming
Difficult to modify
No update
No standards
Pseudocodes
141
Pseudo code is one of the tools that can be used to write a preliminary
plan that can be developed into a computer program
Advantages
Focuses on logic of program without worrying about syntax
Limitations
No visual representation of program logic
No standards
Pseudo code:
Read M1,M2,M3,M4
GRADE (M1+M2+M3+M4)/4
if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
endif
Case Study
Algorithm and Flowchart to calculate slope of a line
146
Algorithm:
Step 1: Start
Step 6: Stop
Case Study
Algorithm and Flowchart to find factorial of a number
147
Algorithm:
Step 1 : Start
Step 2 : Read n
Step 8 : Stop
Case Study
Pseudo code to find factorial of a number
148
Pseudo code:
Input a number n
Initialize counter variable i =1 and factorial=1
while i <= n
factorial = factorial * i
i=i+1
Print factorial of a number
Case Study
Algorithm and Flowchart to find Fibonacci Series
149
Algorithm:
Step 1: Start
Step 7: Stop
Case Study
Flowchart for Snake and Ladder
150
Case Study
Flowchart for Tic-Tac-Toe
151
Start
Print Game
Over and O
Wins
Stop
Top down Design Approach
152
Main Task
Quadratic Solver
Main Task