0% found this document useful (0 votes)
35 views160 pages

PPS - Unit 1

This document provides an introduction to computer systems and problem solving. It discusses basics of computer architecture including processors, memory, and number systems. It also covers problem solving processes, programming paradigms like imperative and object-oriented programming, and programming design tools such as algorithms, pseudocode, and flowcharts. The document outlines the contents to be covered in the unit, including computer basics, generations of computers from first to fifth generation, computer classification by type and size, types of processors and memory including primary and secondary storage.

Uploaded by

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

PPS - Unit 1

This document provides an introduction to computer systems and problem solving. It discusses basics of computer architecture including processors, memory, and number systems. It also covers problem solving processes, programming paradigms like imperative and object-oriented programming, and programming design tools such as algorithms, pseudocode, and flowcharts. The document outlines the contents to be covered in the unit, including computer basics, generations of computers from first to fifth generation, computer classification by type and size, types of processors and memory including primary and secondary storage.

Uploaded by

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

UNIT – 1

INTRODUCTION OF
COMPUTER SYSTEM AND
PROBLEM SOLVING

FYBTEC
H Subject : Programming and Problem Solving
Unit1Contents
2

 Basics of Computers: Architecture, Processors, Memory, Number Systems, Data


Representation- Floating point, Char, String. System Software - Operating system,
Editor, Compiler, Assembler, Linker, Loader.
 Introduction to Problem Solving: Problem solving process/framework,
Programming Paradigms: Imperative, Object Oriented, Functional and Logic
programming. Characteristics of Programming Languages, Role of programming
languages, need of studying programming languages.
 Programming Design Tools: Algorithms, Pseudo-code and Flowchart, Case studies
for Algorithm, Flowchart and Pseudocode. Top-Down and Bottom-Up design
approach. Software Development Life Cycle.
Unit1Contents
3

 Basics of Computers: Architecture, Processors, Memory, Number Systems, Data


Representation- Floating point, Char, String. System Software - Operating system,
Editor, Compiler, Assembler, Linker, Loader.
Introduction to Computer
4

 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

 “Generation” in computer talk is a step in technology

 It provides a framework for the growth of computer industry

 Originally it was used to distinguish between various


hardware technologies, but now it has been extended to
include both hardware and software

 Till today, there are five computer generations


Generation of Computers
7
Some First Generation Computers
8

ENIAC: Electronic Numerical Integrator and EDVAC: Electronic Discrete Variable


Calculator Automatic Computer

EDSAC: Electronic Delay Storage Automatic


Calculator UNIVAC: Universal Automatic Computer
Generation of Computers
9

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

 Electronic Devices Used in Computers of Different


Generations 
Classification of Computer
13

 Computers can be classified as follows:


Classification of Computer
14

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

ii. Analog Computer


An analog computer is a form of computer that
uses continuous physical phenomena such as
electrical, mechanical, or hydraulic quantities to
model the problem being solved

iii. Hybrid Computer


Exhibit features of analog and digital computers
Classification of Computer
15

2. According to Size (capabilities)

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

2. According to Size (capabilities)

iv. Super Computer


 The fastest and most powerful type of computer
 Supercomputers are very expensive and are employed for
specialized applications that require immense amounts of
mathematical calculations
 For example, weather forecasting requires
a supercomputer
Classification of Computer
17

3. According to Purpose

i. General Purpose
General purpose computers are
designed to perform a range of tasks
e.g. Personal Computer

ii. Special Purpose


Specific purpose computers are
designed to handle a specific problem
or to perform a specific task
e.g. Computers that control aircraft and
satellites
Types of Processor
18

 A processor, or "microprocessor," is a small chip that resides


in computers and other electronic devices
 A processor performs arithmetical, logical, input/output (I/O) and other
basic instructions that are passed from an operating system (OS)
 Types of processor depends on the architecture of processor
Types of Processor
19
Types of Processor
20
Computer Storage
21

 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

Types of Computer Storage


Computer Storage
22

Primary Storage and Secondary Storage


Primary Storage
23

 Primary storage (also known as main storage or memory) is the area in


a computer in which data is stored for quick access by the computer's
processor. It consists of Registers, Cache and Main Memory
Primary Storage
24

 Main Memory consists of Random Access Memory (RAM) and Read


Only Memory (ROM)
Random Access Memory (RAM)
25

 It is a read/write (R/W) memory which is volatile


 This means when power is turned off, all the contents are
destroyed
 It can be accessed randomly: that is, any byte of memory can
be accessed without touching the preceding bytes
 RAM is the most common type of memory found in
computers and other devices such as printers
 There are two basic types of RAM:
 Dynamic RAM (DRAM)
 Static RAM(SRAM)
Types of RAM
26

 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

 ROM is non-volatile which means it retains the stored


information even if power is turned off
 It is used to store programs that boot the computer and
perform diagnostics
 Different types of ROM as follows:
 Programmable ROM (PROM)
 Erasable Programmable ROM (EPROM)
 Electrically Erasable Programmable ROM (EEPROM)
Types of ROM
28

 PROM (Programmable ROM): 

 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

 EPROM (Erasable Programmable ROM) : 

 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

 EEPROM (Electrically Erasable Programmable ROM): 

 EEPROM is a special type of PROM that can be erased by exposing it to an


electrical charge
 Like other types of PROM, EEPROM retains its contents even when the power
is turned off
 Also, like other types of ROM, EEPROM is not as fast as RAM
 EEPROM is similar to Flash Memory (sometimes called flash EEPROM)
 The principal difference is that EEPROM requires data to be written or
erased one byte at a time whereas flash memory allows data to be written or
erased in blocks
Secondary Storage
30

 Secondary Storage is alternatively referred to as


external memory, secondary memory or auxiliary storage
 Secondary storage device is a non-volatile device that holds
data until it is deleted or overwritten

 Primary storage  Secondary storage


 Volatile  Nonvolatile
 Temporary  Permanent
 It loses all of its contents  Writing : is the process
when power to the system
of saving information
unit is shut off
 Reading: is the process
of accessing information
Secondary Storage
31

 Secondary Storage devices are classified as follows:


Secondary Storage
32

 Sequential-access Storage Devices


 Arrival at the desired storage location may be preceded by sequencing through other
locations
 Data can only be retrieved in the same sequence in which it is stored 
 Magnetic tape is a typical example of such a storage device
Secondary Storage
33

 Direct-access Storage Devices


 Devices where any storage location may be selected and accessed at random
 Permits access to individual information in a more direct or immediate manner
 Magnetic and optical disks are typical examples of such a storage device

Memory Storage
Devices

Magnetic Disks
Number System
34

 A number system is a collection of various symbols


which are called digits

 Two types of number systems are:


 Non-positional Number Systems
 Positional Number Systems
Non-positional Number System
35

 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:

 Has only 2 symbols or digits (0 and 1). Hence its base = 2

 The maximum value of a single digit is 1 (one less than the value of the base)

 Each position of a digit represents a specific power of the base (2)

 This number system is used in computers


Decimal Number System
38

 Characteristics:

 Has 10 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7,8, 9). Hence, its base = 10

 The maximum value of a single digit is 9 (one less than the value of the base)

 Each position of a digit represents a specific power of the base (10)

 We use this number system in our day-to-day life


Octal Number System
39

 Characteristics:

 Has total 8 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7). Hence, its base = 8

 The maximum value of a single digit is 7 (one less than the value of the base)

 Each position of a digit represents a specific power of the base (8)

 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)

 Each position of a digit represents a specific power of the base (16)

 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:

 Reverse the remainders, we get 11100000000


 (1792)10 = (11100000000)2 E.x 160, 266, 84, 2540 etc.
Conversions
42

 Decimal to Octal
 Here is an example of using repeated division to convert 1792
decimal to octal:

 Reverse the remainders, we get 3400



(1792)10 = (3400)8 , Ex 1032, 574, 680 etc
Conversions
43

 Decimal to Hexadecimal
 Here is an example of using repeated division to convert 1792
decimal to hexadecimal:

 Reverse the remainders, we get 700


 (1792)10 = (700)16
 Ex. 590, 479, 2545 etc.
Conversions
44

 The only addition to the algorithm when converting from decimal to


hexadecimal is that a table must be used to obtain the hexadecimal digit if
the remainder is greater than decimal 9.

 For example, 590 decimal converted to hex is:


Hexadecimal
Decimal Number Operation Quotient Remainder
Result
590 ÷ 16 = 36 14 E
36 ÷ 16 = 2 4 4
2 ÷ 16 = 0 2 2
0 done.

 Reverse the remainders, we get 24E


 (590)10 = (24E)16
Conversion from other to decimal
number system
45
Conversion from Binary to octal
46

 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 − Convert each octal digit to a 3 digit binary number


(the octal digits may be treated as decimal for this
conversion).
 Step 2 − Combine all the resulting binary groups (of 3 digits
each) into a single binary number.
 Example
Binary Number − 101012
Calculating Octal Equivalent −
Step Octal Number Binary Number
1. 258 28 58
2. 258 0102 1012
3. 258 0101012
Octal Number − 258 = Binary Number − 101012
Conversion from binary to Hexadecimal
48

 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

 Step 1 − Convert each hexadecimal digit to a 4 digit binary


number (the hexadecimal digits may be treated as decimal for
this conversion).
 Step 2 − Combine all the resulting binary groups (of 4 digits
each) into a single binary number.
 Example
Binary Number − 101012
Calculating Octal Equivalent −
Step Hexadecimal Number Binary Number
1. 1516 116 516
2. 1516 00012 01012
3. 1516 000101012
Hexadecimal Number − 1516 = Binary Number − 101012
Octal to Hexadecimal
50

 When converting from octal to hexadecimal, it is often easier to first


convert the octal number into binary and then from binary into
hexadecimal.
 For example, to convert 345 octal into hex:(from the previous example)
 Octal  =345
Binary =011 100 101

Drop any leading zeros or pad with leading zeros to get groups of four
binary digits (bits):
Binary 011100101 = 1110 0101

Then, look up the groups in a table to convert to hexadecimal digits.


 Binary =1110 0101 Hexadecimal =E5= E5 hex
51

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

 When converting from hexadecimal to octal, it is often easier to first


convert the hexadecimal number into binary and then from binary into
octal.
 For example, to convert A2DE hex into octal:
 Hexadecimal =A 2 D E
 Binary =1010 0010 1101 1110 = 1010001011011110
 Add leading zeros or remove leading zeros to group into sets of three
binary digits.
 Binary: 1 010 001 011 011 110 = 001 010 001 011 011 110
 Then, look up each group in a table:
Binary 000 001 010 011 100 101 110 111
Octal 0 1 2 3 4 5 6 7

Binary =001010001011011110 Octal =121336


Data Representation
53

 Computer uses a fixed number of bits to represent a piece of data, which


could be a number, a character, or others

 A n-bit storage location can represent up to 2^n distinct entities

 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

 Integers, for example, can be represented in 8-bit, 16-bit, 32-


bit or 64-bit

 Besides bit-lengths, there are two representation schemes for


integers:
1. Unsigned Integers: can represent zero and positive
integers
2. Signed Integers: can represent zero, positive and negative
integers
Data Representation: Unsigned
56

 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:

1×2^0 + 1×2^6 = 65D 1×2^3 + 1×2^12 = 4104D


Data Representation: Unsigned
57

 An n-bit pattern can represent 2^n distinct integers. An n-bit unsigned


integer can represent integers from 0 to (2^n)-1, as tabulated below:
n Minimum Maximum
8 0 (2^8)-1  (=255)

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)

• An 8-bit unsigned integer


has a range of 0 to 255
Data Representation: Signed
58

 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:

Suppose n=8 and Suppose n=8 and


binary representation is 0 100 0001B binary representation is 1 000 0001B

Sign bit is 0 ⇒ positive Sign bit is 1 ⇒ negative

Absolute value is 100 0001B = 65D Absolute value is 000 0001B = 1D

Hence, the integer is +65D Hence, the integer is -1D

Example 3: Example 4:

Suppose n=8 and Suppose n=8 and


binary representation is 0 000 0000B binary representation is 1 000 0000B

Sign bit is 0 ⇒ positive Sign bit is 1 ⇒ negative

Absolute value is 000 0000B = 0D Absolute value is 000 0000B = 0D

Hence, the integer is +0D Hence, the integer is -0D


Data Representation: Signed
60

The drawbacks of sign-magnitude representation are:

1. There are two representations (0000 0000B and 1000 0000B) for the


number zero, which could lead to inefficiency and confusion.

2. Positive and negative integers need to be processed separately.


Complement of a number
61

 Complements are used in the digital computers in order to


simplify the subtraction operation and for the logical
manipulations
 Binary system complements
 As the binary system has base r = 2. So the two types of complements
for the binary system are 2's complement and 1's complement

 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

 Example of 2's Complement is as follows:

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

 In computer memory, character are "encoded" (or "represented") using a


chosen "character encoding schemes" 

 It is important to note that the representation scheme must be known


before a binary pattern can be interpreted

 e.g. the 8-bit pattern "0100 0010 B" could represent anything under the
sun known only to the person encoded it

 The most commonly-used character encoding schemes are:


 7-bit ASCII
 Unicode
ASCII
70

 It is an acronym for the American Standard Code for Information


Interchange

 It is a standard seven-bit code that was first proposed by the American


National Standards Institute or ANSI in 1963, and finalized in 1968 as
ANSI Standard X3.4

 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

 An uppercase "A," for example, is represented by the decimal number 65."


 By looking at the ASCII table, you can clearly see a one-to-one correspondence
between each character and the ASCII code used.

• For example, 32 is the ASCII


code for a space

• Code numbers 
• 65  to 90 represents 'A' to 'Z'
• 97  to 122 represents 'a' to 'z'
• 48 to 57 represents '0' to '9'

ASCII - Binary Character Table


(Sample)
Unicode
72

 In the pre-Unicode environment, we had 8-bit characters, which limited us to a


maximum limit of 256 characters
 No single encoding could contain enough characters to cover all the languages
 Many encoding schemes are in conflict of each other, i.e., the same code number is
assigned to different characters

 Unicode aims to provide a standard character encoding scheme, which is universal,


efficient, uniform and unambiguous. 
 Unicode is a computing industry standard for the consistent encoding,
representation and handling of text expressed in most of the world's writing
systems

 Unicode provides a unique number for every character:


 no matter what the platform
 no matter what the program
 no matter what the language
Unicode
73

 Where is Unicode Used?


 The Unicode standards has been adopted by many software and
hardware vendors
 Most OSs support Unicode
 Unicode is required for international document and data interchange
 Programming languages such as Java, C#, Perl, Python
 Markup Languages such as XML, HTML, XHTML, JavaScript

 Unicode Transformation Format (UTF)


 An algorithmic mapping from virtually every Unicode code point to a
unique byte sequence
 UTF Encodings Types
 UTF-8
 UTF-16
 UTF-32
Data Representation: String
74

 Being able to represent individual characters in specified memory


locations is very useful, but it is not very convenient for the way we
normally want to work with text information.
 Typically, when we work with text, we work with "strings" of characters.
 The obvious way to represent a string in memory is as a sequence of
ASCII codes - and this is exactly what is done.

 Endianess (or byte-order):


 For a multi-byte character, you need to take care of the order of the bytes in storage.
 In big endian, the most significant byte is stored at the memory location with the
lowest address (big byte first).
 In little endian, the most significant byte is stored at the memory location with the
highest address (little byte first).
Software
75

 Software refers to a collection of programs


 There are two types of software:
1. System Software
2. Application Software

 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

 Application software are designed to solve a specific problem or to do a


specific task
 e.g. MS Word, Paint, Web Browsers (like Chrome, Mozilla Firefox etc.)
Introduction to System Software
76

 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

 The OS boots up the computer and makes sure everything is operational.

 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

 Source Code Editor is an standalone application required for writing


or editing the source code. A source code editor checks for syntaxes
while user writes a code and immediately warns of syntax errors.

 Text Editor is a simple application required for editing plain text such
as notepad.
Introduction to System Software
79

 Compiler: 

 It is a program which translates a high level language program into a


machine language program.
 A compiler is more intelligent than an assembler. It checks all kinds of
limits, ranges, errors etc. 
Introduction to System Software
80

 Assembler:

 A computer will not understand any program written in a language,


other than its machine language
 The programs written in other languages must be translated into the
machine language
 Such translation is performed with the help of software
 A program which translates an assembly language program into a
machine language program is called an assembler
Introduction to System Software
81

 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: 

 Loader is a program that loads machine codes of a program into the


system memory
 In Computing, a loader is the part of an Operating System that is
responsible for loading programs
 It is one of the essential stages in the process of starting a program,
because it places programs into memory and prepares them for
execution
 Loading a program involves reading the contents of executable file into
memory
 Once loading is complete, the operating system starts the program by
passing control to the loaded program code
Steps to execute a High Level Program
83

Example: C Program Execution


Unit-1 Contents
84

 Introduction to Problem Solving: Problem solving process/framework,


Programming Paradigms: Imperative, Object Oriented, Functional and Logic
programming. Characteristics of Programming Languages, Role of programming
languages, need of studying programming languages.
Computer Programming– Three Stages
85

 Computer programming can be divided into three distinct areas


of activity:
1. Problem definition and problem solving

2. Creating a structured solution (or algorithm)

3. Coding (e.g. C, Java, C++)


 Consider an example as case of customer while marketing
• Specify the problem
• Solve the problem
• Specify solution in structured format
Problem Solving, Algorithm Development
and Coding
86

 In problem solving, algorithm development and coding we tend to


view problems at different levels of abstraction.

 Problem solving is done at a high level of abstraction. Much of


the detail is omitted at this stage in order that the problem can be
more easily specified and solved.
 Algorithm development works at a lower level of abstraction
than problem solving. It contains much of the detail that will
eventually become the program. However, it still omits the finer
detail required in the final compute program

 Coding works at a very low level of abstraction. Programming


code must be written with every single detail a computer needs
to carry out a task included.
Contd…
87

 Problem solving, algorithm development and coding


are also different in terms of the language that is used
to complete the activity:
 Problem solving is generally done using use

natural, everyday language


 Algorithm development is done using a specialist,

semi-structured language (pseudo code)


 Coding is done using a highly-structured
(programming) language that is readable by
machines
What is a Problem?
88

 There are many different kinds of problems:


 How do I get to Oxford from London?
 Why is it wrong to lie?
 For a problem to be solvable through the use of a
computer, it must generally:
 Be technical in nature with objective answers that can be
arrived at using rational methods
 Be well-structured
 Contain sufficient information for a solution to be found
 Contain little, if any, ambiguity.
When Can You Use a Problem Definition?
89

 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

 An outline framework for problem solving:


1. Understand the problem

2. Devise a plan to solve the problem

3. Carry out the plan

4. Assess the result

5. Describe what has been learned from the process

6. Document the solution.

 In Vickers, this framework is called the How to Think Like a


Programmer (HTTLAP) approach to problem solving.
Understanding the Problem
92

 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

 We need to remove any information that is extraneous


to the problem
 We need to determine our knowns and our unknowns

 We need to be aware of any assumptions we are


making.
Devise a plan to the solve the problem
93

 If a problem contains a set of sub-problems, in what order


are you going to solve them?
 How are you going to represent the problem:

 Numerically?
 Graphically?
 Tabular data?
 Natural language?
 Does the problem lend itself to a particular problem

solving strategy or strategies:


 Working backwards?
 Logical reasoning?
 Finding a pattern?
 Accounting for all possibilities?
Carry Out the Plan
94

 Consider the following problem:


In a room with ten people, everyone shakes hands with
everyone else exactly once. In total, how many handshakes
are there?
 How would you represent and solve the problem?
 Different strategies to be used
Assessing the Results
95

 It is very unusual when solving complex problems to achieve


the correct result first time round.
 To verify our solutions are correct, we need to take a few
steps backwards:
 Was our understanding of the problem correct?

 Did we overlook anything?

 Did we choose the correct strategy?

 Did we employ that strategy correctly?

 Have we made any incorrect or unwitting assumptions?

 However, it is often very difficult to spot our own mistakes. It


is often better, therefore, to have somebody else verify our
solutions for us.
Contd…
96

 Sometimes solutions appear correct, but are in fact


wrong, due to an initial misunderstanding of a
problem (What Vickers calls, errors of the third
kind).
 If you have misunderstood a problem, it does not
matter how good a coder you are, your program will
not work as it is supposed to.
 Therefore getting the problem-solving part of
programming right is absolutely essential if we are to
build programs that work as they are supposed to
work.
Describing What you have Learned
97

 You can only become a good problem solver by


reflecting on your experiences of problem solving.
 Keeping a record of problems you have attempted,
your success, failures, the approaches you have
used, etc. will:
 Broaden your problem solving repertoire
 Help you to recognize similarities/patterns in problems
 Help you identify and fix logical or implementation
errors
 Help you to solve problems faster and more effectively
Documenting the Solution
98

 Documenting a solution will help you to generalize your


approach to other similar problems.
 Do you recognize the following type of problem? How would
you solve it?

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?

 It will also prevent you forgetting how you arrived at your


solutions.
 In the long run, it will make you a better problem solver and
eventually a better programmer.
Computer Problem-Solving
99
The Interactions Between Problem-Solving
Phases
100
Conveying solution in a formal language
101

Purpose of program planning


 To write a correct program, programmer must write

each and every instruction in the correct sequence.


 Logic (instruction sequence)of the program can be
very complex.
 Hence program must be planned before they are

written to ensure program instructions are:


 Appropriate for the problem

 In the correct sequence


Programming Paradigms
102

A programming paradigm is a pattern of problem-


solving thought that underlies a particular genre of
programs and languages.
There are four main programming paradigms:
 Imperative
 Object-oriented
 Functional
 Logic (declarative)
Imperative Paradigm
103

Follows the classic von Neumann-Eckert model:


 Program and data are indistinguishable in memory
 Program = a sequence of commands
 State = values of all variables when program runs
 Large programs use procedural abstraction

Example imperative languages:


 Cobol, Fortran, C, Ada, Perl, …
The von Neumann-Eckert Model
104
Object-Oriented (OO) Paradigm
105

An OO Program is a collection of objects that interact


by passing messages that transform the state.
When studying OO, we learn about:
 Sending Messages
 Inheritance
 Polymorphism
Example OO languages:
Smalltalk, Java, C++, C#, and Python
Contd…
106
Functional Paradigm
107

Functional programming models a computation as a


collection of mathematical functions.
 Input = domain
 Output = range
Functional languages are characterized by:
 Functional composition
 Recursion
Example functional languages:
 Lisp, Scheme, ML, Haskell, …
Functional vs Imperative
108

 Compute Factorial Function


 In Imperative Programming Languages:
fact(int n) {
if (n <= 1) return 1;
else
return n * fact(n-1);
}
 In Functional Programming Languages: Scheme
(define (fact n)
(if (< n 1) 1 (* n (fact (- n 1)))
))
Logic Paradigm
109

Logic programming declares what outcome the program


should accomplish, rather than how it should be
accomplished.
When studying logic programming we see:
 Programs as sets of constraints on a problem
 Programs are expressed as rules in formal language
 Programs that achieve all possible solutions
 Programs that are nondeterministic
Example logic programming languages:
 Prolog
Summary: Programming Paradigm

 Imperative Programming
 Follows the classic von Neumann-Eckert model

 Variables, assignment statements, and iteration

 e.g. C, Fortran ,Pascal

 Object Oriented Programming


 Class and Object based.

 e.g. C++,JAVA ,Python


Summary: Programming Paradigm

 Functional Programming
 Computing by applying functions to given parameters

 e.g. LISP, Scheme, ML,Haskell

 Logic Programming
 Rule-based (rules are specified in no particular order)

 e.g. Prolog
What is Programming Language
112

◻ A programming language is a notational system for


describing computation in machine-readable and
human-readable form.
◻ A programming language is a tool for developing
executable models for a class of problem domains.
What is Programming Language
113

◻ English is a natural language. It has words, symbols


and grammatical rules.
◻ A programming language also has words, symbols
and rules of grammar.
◻ The grammatical rules are called syntax.
◻ Each programming language has a different set of
syntax rules.
Characteristics of Programming Languages
114

◻ 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

◻ Several programming constructs supported by the language


must match well with the application area it is being used for.
◻ The programs developed in the language must make efficient
use of memory as well as other computer resources.
◻ The language must provide necessary tools for development,
testing, debugging, and maintenance of a program. All these
tools must be incorporated into a single environment known
as Integrated Development Environment (IDE), which enables
the programmer to use them easily.
◻ The language must be consistent in terms of both syntax and
semantics.
Role of Programming Languages
116

◻ A programming language is formal language that specifies a


set of instructions that can be used to produce various kinds of
output .
◻ Programming languages generally consist of instructions for a
computer .
◻ Programming languages can be used to create programs that
implement specific algorithms.
Cont’d…
117

Steps in learning English Language-

Alphabets Words Sentences Paragraph

Steps in learning C-Language-

Alphabets/
Constants/
Digits/ Program
Variables/ Instructions
Special
Keywords
Symbols
Need to Study Programming Language
118

◻ To improve your ability to develop effective algorithms.


◻ To improve your use of existing programming languages.
◻ To increase your vocabulary of useful programming
constructs.
◻ To allow a better choice of programming language.
◻ To make it easier to learn a new language.
◻ To make it easier to design a new language.
Unit-1 Contents
119

 Programming Design Tools: Algorithms, Pseudo-code and Flowchart, Case


studies for Algorithm, Flowchart and Pseudocode. Top-Down and Bottom-Up
design approach. Software Development Life Cycle.
Algorithm, Flowchart and Pseudo
Code
120

 A typical programming task can be divided into two phases:

1. Problem solving phase


 produce an ordered sequence of steps that describe solution of
problem
 this sequence of steps is called an algorithm
2. Implementation phase
 implement the program in some programming language
Algorithm, Flowchart and Pseudo
Code
121

 Algorithms, Flowcharts and Pseudo Codes are different


tools used for creating new programs, especially in
computer programming
 Algorithm
 Set of step-by-step instructions that perform a specific task or operation
 It is a Natural language and NOT programming language
 Flowchart
 Visual program design tool
 Semantic symbols describe operations to be performed
 Pseudo code
 Set of instructions that mimic programming language instructions
What is an Algorithm?
122

 Step-by-step description of how to achieve a solution


for a given problem
 refers to the logic of the program or sequence of
instructions
 It is defined as a sequence of instructions that when
executed in the specified sequence, the desired results
are obtained.
Algorithm
123

 Algorithm is a representation of a solution to a problem

 It is commonly used for data processing, calculation and other


related computer and mathematical operations

 To be an algorithm, a set of rules must be unambiguous and


have a clear stopping point
Characteristics of an Algorithm
124

 Should be precise and unambiguous


 Should be executed in a finite time

 Should not be repeated infinitely. algorithm will


ultimately terminate.
 Desired results are obtained

 Must have start and stop steps


Example
125

 Algorithm to add two given numbers:


Step 1: START
Step 2: Read two numbers A and B
Step 3: Add numbers A and B and store result in C
Step 4: Display C
Step 5: STOP
Example
126

Write an algorithm to find the largest among three


different numbers entered by user.
Step 1:START
Step 2:Declare variables a,b and c.
Step 3:Read variables a,b and c.
Step 4:If a>b
If a>c
Display a is the largest number.
Else
Display c is the largest number.
Contd…
127

Else
If b>c
Display b is the largest number.
Else
Display c is the largest number.
Step 5:STOP
Generalized Algorithm
128

 Logic written in universal or general terms


 Algorithms are written in general languages which
can be used by any one
 Knowledge of programming language is not
required
 Only solution of problem is given, implementation
details are not required
 Becomes easy to find solution
 Anyone can refer this algorithms
How to Make Algorithms Generalized
129

 Solve problem by person who will not be


expert in implementation
 Use generalized logic to solve problem
Infinite Loop
130

 Loop mean repeat set of instruction till specific


condition is true
 Infinite loop is endless loop, i.e. it never ends
 Infinite loop occurs when condition remains always
true or no termination condition exists
 Due to infinite loop, program never ends
Avoiding Infinite Loops
131

Avoided by limiting the number of repetitions of


loop
Two ways:
 By counting fixed count is used for repeating

loop
 By using sentinel value It is special value

whose presence guarantees termination of


loop
Different Ways to Represent an Algorithm

132

 As a flowchart
 As a pseudocode
 As a program
Program Planning Tools
133


Flowchart
 Structure charts
 Pseudo codes
Flowchart
134

 Flowchart is a tool developed in the computer industry, for


showing the steps involved in a process

 A flowchart is a diagram made up of boxes, diamonds and


other shapes, connected by arrows - each shape represents a
step in the process, and the arrows show the order in which they
occur

 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

shapes and logical flow is indicated by


arrows
 Boxes represent different operations

 Arrows shows sequence of operations

 Helps to understand logic of program


Flowchart Symbols
136
Flowchart Examples
137

Add two numbers and display result

START

Read A and B

C=A+B

Display C

STOP
Flowchart Examples
138

Find the largest of given two numbers

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

 Proper Program Documentation

 Effective Coding

 Systematic Debugging

 Systematic Testing

 Limitations:
 Time consuming

 Difficult to modify

 No update

 No standards
Pseudocodes
141

 “Pseudo” – imitation or false


 “Code” – instructions written in a programming
language
 Combination of English and Programming Language
 Focuses on developing the logic of the program
without worrying about the syntax
Pseudo Code
142

 Pseudo code is one of the tools that can be used to write a preliminary
plan that can be developed into a computer program

 Pseudo code is a generic way of describing an algorithm without use of


any specific programming language syntax

 It is, as the name suggests, pseudo code i.e. it cannot be executed on a


real computer, but it models and resembles real programming code, and is
written at roughly the same level of detail

 Computer science textbooks often use pseudo code in their examples so


that all programmers can understand them, even if they do not all know
the same programming languages
Example
143

Accept two numbers :-

if first number > second number


display “First number is greater”
else
display “ second number is greater”
Advantages and Limitations
144

 Advantages
 Focuses on logic of program without worrying about syntax

 Language independent; can be translated to any computer


language code
 Easier to develop program from pseudocode than flowchart

 More concise, readable, and easier to modify

 Limitations
 No visual representation of program logic

 No standards

 Cannot be compiled and executed hence correctness cannot


be verified
Example:
Algorithm, Flowchart and Pseudo Code
145

 Determine a student’s final grade indicating whether he/she is passing


or failing. The final grade is calculated as the average of four marks.
Algorithm:
Step 1: Start
Step 2: Input a set of four marks
Step 3: Calculate the grade by adding and dividing by 4
Step 4: if grade is below 50
Print “FAIL”
else
Print “PASS”
Step 5: Stop

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 2: Input x and y coordinates of line as


x1, y1, x2, y2

Step 3: if x1 and x2 are equal then


Print “Line is Vertical“
Go to Step 6
else if y1 and y2 are equal then
Print “Line is Horizontal“
Go to Step 6
else Go to Step 4

Step 4: Find Slope as y2-y1/x2-x1

Step 5: Print Slope of Line

Step 6: Stop
Case Study
Algorithm and Flowchart to find factorial of a number
147

Algorithm:

 Step 1 : Start

 Step 2 : Read n

 Step 3 : Initialize counter variable i to 1 and fact to 1

 Step 4 : if i < n go to step 5 otherwise goto step 7

 Step 5 : increment counter variable i

 Step 6 : calculate fact = fact * i and goto step 4

 Step 7 : Print fact

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 2: Declare variables N, N1, N2, N3, i

Step 3: Initialize variables N1 = 0, N2 = 1, i = 0

Step 4: Read value of N from user

Step 5: Display N1, N2  

Step 6: Repeat following statements until i <  N - 2


Compute N3 = N1 + N2
N1 = N2
N2 = N3  
i  = i + 1
Display N3

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

Print Game Print Game Over


Draw and X Wins

Stop
Top down Design Approach
152

 Top down Design Model


 In top-down model, an overview of the system is
formulated, without going into detail for any part of it.
 Each part of the system is then refined in more details.
 Each new part may then be refined again, defining it in
yet more details until the entire specification is detailed
enough to validate the model.
Top down Design
153

 Top down Concept in Problem Solving


 If we look at a problem as a whole, it may seem impossible to
solve because it is so complex. Examples:
 writing a University System program
 writing a word processor
 Complex problems can be solved using top-down design,
also known as stepwise refinement, where
 We break the problem into parts
 Then break the parts into parts
 Soon, each of the parts will be easy to do
Top down Design
154

Main Task

Subtask 1 Subtask 2 Subtask 3


Top down Design
155

Quadratic Solver

getEquation getDelta getSolution


Advantages of Top-down Design
156

 Breaking the problem into parts helps us to clarify


what needs to be done.
 At each step of refinement, the new parts become
less complicated and, therefore, easier to figure out.
 Parts of the solution may turn out to be reusable.
 Breaking the problem into parts allows more than
one person to work on the solution.
Bottom-up Design Approach
157

 In bottom-up design individual parts of the system


are specified in details.
 The parts are then linked together to form larger
components, which are in turn linked until a
complete system is formed.
 Object-oriented languages such as C++ or JAVA
use bottom-up approach where each object is
identified first.
Bottom up Design
158

Main Task

Subtask 1 Subtask 2 Subtask 3


Software Development Life Cycle (SDLC)
159

 The software development life cycle (SDLC) is a framework


defining tasks performed at each step in the software
development process
 SDLC is a structure followed by a development team within
the software organization
 It consists of a detailed plan describing how to develop,
maintain and replace specific software
 The life cycle defines a methodology for improving the
quality of software and the overall development process
Software Development Life Cycle (SDLC)
160

You might also like