Unit I
Unit I
UNIT I INTRODUCTION 8
TOTAL: 45
PERIODS
TEXTBOOKS:
1. Anita Goel and Ajay Mittal, “Computer Fundamentals and Programming in C”,
Dorling
Kindersley (India) Pvt. Ltd., Pearson Education in South Asia, 2011.
2. Pradip Dey, Manas Ghosh, “Fundamentals of Computing and Programming in
C”, First
Edition, Oxford University Press, 2009
3. Yashavant P. Kanetkar. “ Let Us C”, BPB Publications, 2011.
REFERENCES:
INTRODUCTION TO COMPUTERS
1.1 DEFINITION
1.2.1 Education
Payroll calculations
Budgeting
Sales analysis
Financial forecasting
1.2.3 Banking
Today banking is almost totally dependent on computer.
ATM machines are making it even easier for customers to deal with banks.
1.2.4 Insurance
Insurance companies are keeping all records up-to-date with the help of
computers. The insurance companies, finance houses and stock broking firms
are widely using computers for their concerns.
maturity date
interests due
survival benefits
bonus
1.2.5 Marketing
In marketing, uses of computer are following:
Some major fields of health care in which computers are used are:
Diagnostic System - Computers are used to collect data and identify
cause of illness.
Lab-diagnostic System - All tests can be done and reports are prepared
by computer.
One of major areas is CAD (Computer aided design). That provides creation and
modification of images. Some fields are:
1.2.8 Military
Computers are largely used in defence. Modern tanks, missiles, weapons etc.
Military also employs computerised control systems. Some military areas where
a computer has been used are:
Missile Control
Military Communication
Smart Weapons
1.2.9 Communication
E-mail
Chatting
Usenet
FTP
Telnet
Video-conferencing
1.2.10 Government
Budgets
Sales tax department
Male/Female ratio
Weather forecasting
1.3 OVERVIEW OF COMPUTER
Hardware
Software
1.3.1 HARDWARE
3.
Keyboard
4.Mouse 5.Printer
ii. Monitor
Keyboard and mouse are input devices, which are used to get input from
the user. A keyboard is a typewriter-style device, which uses an arrangement of
buttons or keys, to act as mechanical levers or electronic switches. Following the
decline of punch cards and paper tape, interaction via teleprinter-style
keyboards became the main input device for computers. A mouse is a pointing
device that detects two-dimensional motion relative to a surface. This motion is
typically translated into the motion of a pointer on a display, which allows for fine
control of a graphical user interface.
There are various components of computer which are used for ideal
purposes. Some of the computer devices are
1. Printer
2. Speaker
3. DVD
4. Floppy Disk etc
1.3.3 SOFTWARE
i. System Software
Example: Games, Tally, VLC media player, CAD etc. There are thousands of
applications available to help the user to perform the desired tasks.
The computers have five basic operations to carry out any specified task.
i. Input: It is the process of capturing the information or raw data from the user.
ii. Process: It is the transformation process of converting input into output.
iii. Output: It is the result or outcome of the process.
iv. Storing: It is the process of saving the data or information or instruction,
which can be retrieved whenever it is required
v. Controlling: It is the process of directing the sequence in which all the
operations are to be performed.
i. Speed
ii. Accuracy
iii. Versatility
iv. Diligence
v. Storage
vi. Reliability
vii. Resource sharing
i. Speed
Computer is a fast electronic device that can perform large and complex
problems in few seconds. Computers process data at fast rate, i.e., millions of
instructions per second. Speed of the computer is calculated in MHz (Mega
Hertz). Computer s work at very high speed and are much faster than humans.
ii. Accuracy
iii. Versatility
Computers are versatile in nature used for many purpose. Computers
perform multiple tasks simultaneously. For example: User can type letter, browse
internet, play music, can print a document etc at same time.
iv. Diligence
v. Storage
1 Byte 8 bit
1 KB 1024 bytes
1 MB 1024 KB
1 GB 1024 MB
1 TB 1024 GB
KB = Kilo Byte
MB = Mega Byte
GB = Giga Byte
TB = Tera Byte
vi. Reliability
Over the years, various computing devices were invented that enabled
people to solve different types of problems. All these computing devices can be
classified into several generations. Generations refers to the phases of
improvement made to different computing devices resulted in a small, cheap,
fast and reliable computer. There are five generations of computer.
First Generation Computers
Second Generation Computers
Third Generation Computers
Fourth Generation Computers
Fifth Generation Computers
Vacuum Tubes
Input was based on Punched Cards and paper tape. Output was in the form of
Printouts. Machine Language (i.e., 0 & 1) is used to perform operations of
computer. First Generation computers can solve only one problem at a time.
Some examples of first generation computers are
ENIAC Electronic Numerical Integrator and Calculator
EDVAC Electronic Discrete Variable Automatic Computer
EDSAC Electronic Delay Storage Automatic Calculator
UNIVAC Universal Automatic Computer
Advantage
Transistors
Advantage
Disadvantage
Cost of these computers was very high.
It need air-conditioning
Commercial products were difficult.
Integrated Circuit(IC)
Advantage
Disadvantage
Microprocessors
Advantage
Disadvantage
Advantage
Disadvantage
Oper Opera
Technol
Gener Yea Input & Langua ating ting Applicatio Exampl
ogy
ation r Output ge Used Syst Spee n e
Used
em d
Punched
194 Machine ENIAC
Card, Simple
0- Vacuum Languag Millise EDVAC
First Paper None business
195 Tube e i.e., 0 conds EDSAC
Tape & application
6 &1 UNIVAC
Printout
PDP-8
195 Assembl Business
Punched Micros IBM
6- y and
Second Transistor Card & None econd 1401
196 Languag scientific
Printout s IBM
3 e research
7090
High
level
196 Integrate Languag Business
Nanos
4- d Keyboard e, Basic, and NCR 395
Third Yes econd
197 Circuit(IC & Monitor COBOL, scientific B6500
s
0 ) Pascal, research
C, C++
etc
High
Engineering
level
197 Microproc Keyboard, 1 to Design,
Languag Apple
0- essor & Mouse,GU 10 Scientific
Fourth e, C, C+ Yes Series I
Till LSI, VLSI I& Nanos research,
+, JAVA, & II
Date & ULSI Monitor econd online
Oracle,
systems.
SQL etc
High 1 to
198 Speech
level 100
6-at VLSI & recognition, Robotics
Fifth Languag Yes Nanos
pres SLSI Robotics , AI etc
e, 3GL, econd
ent etc
4GL etc s
1.6 CLASSIFICATION OF COMPUTERS
Now-a-days computers are available in different types. The function of each type
of computer is to process data and provide some output to users. Computers are
classified based on three criteria’s.
i. Analog Computer
Disadvantage
Digital computers stores and process the data in a digital form. Each type
of data is stored in terms of 0s and 1s. Output produced by these computers is
also in the digital form. The digital computer is also known as digital information
processing system. Digital computers are generally faster and more reliable than
the analog computer systems and provide more accurate results. The computer
used by a home user is a typical example of a digital computer. It is used in
colleges, universities and business. Different hardware components of a digital
computer are ALU(Arithmetic and Logical Unit), CU(Control Unit), memory unit
and I/O units.
Advantage
Advantage
Computers are designed for designed for different purpose so that they
can perform their tasks according to their capabilities. On the basis of different
applications or purposes, computers can be classified into the following
categories.
Example: Computer used for satellite launching, Aircraft controlling system etc.
Computers differ from each other in terms of their shape, size and
weights. Based on the size and their capacity, computers can be classified into
four categories.
i. Micro Computer
Examples:
Advantage
Disadvantage
Examples:
A laptop is a portable computer that a user can carry around. Since the
laptop resembles a notebook, it is also known as notebooks ..
The biggest advantage of laptops is that they are lightweight and can be
used anywhere and at any time, especially while travelling.
Moreover, they do not need any external power supply as a rechargeable battery
is completely self-contained. However, they are expensive as compared to
desktop computers.
Net Book
These computers are as powerful as desktop but size of these computers are
comparatively smaller than laptop and desktop. They weigh 2 to 3 kg. They are
more costly than laptop.
Tablet computer
It is portable computer. Tablet computer are the new kind of PCs. It will
be use a stylus or a pen, or a keyboard and mouse.
The monitor is very small and is the only apparent form of output. Since
these computers can be easily fitted on the top of the palm, they are also
known as palmtop computers.
Apple Newton, Casio Cassiopeia, and Franklin eBook Man are some of
the examples of hand-held computers.
Smart phones
Smart phones are cellular phones that can be act as a phone and as a
small PC. It will be use a stylus or a pen, or a small keyboard. They can be
connected to the internet wirelessly. They are used to access the e-mail,
download music, play games, etc.
Blackberry, Apple, HTC, Nokia and LG are some of the manufactures of smart
phones.
Advantage
They are used for real time applications like industries, research centres
etc.
Occupies less space the mainframe
Economically effective than mainframe
Disadvantage
Mainframe computer are large powerful system and operate at a very high
speed. They are multi-user, multi-programming and high performance computer.
Mainframe computers are used in organization like bank or companies, where
many people require frequent access to the same data.
Advantage
Disadvantage
Too expensive.
Occupies more space.
iv. Super Computer
Advantage
Disadvantage
Largest in size and most expensive in price than any other variety.
1.7 BASIC ORGANIZATION OF COMPUTER
Input Unit
CPU
Memory Unit
Output Unit
Cache
Memory
Register
ALU
Control Unit
CPU
Keyboard
Keyboard is the standard input device attached to all the computers. The
layout of the keyboard is just like the traditional typewriter of the type QWERTY.
It also contains some extra command keys and function keys. It contains a total
of 101 to 104 keys. A typical keyboard used in a computer is shown in figure.
You have to press correct combination of keys to input data. The computer
can recognize the electrical signals corresponding to the correct key combination
and processing is done accordingly.
Mouse
Scanner
The keyboard can input only text through keys provided in it. If we want to
input a picture the keyboard cannot be used. Scanner is an optical device that
can input any graphical matter and display it back. The common optical scanner
devices are OMR, OCR and MICR.
i. OMR
ii. OCR
iii. MICR
Card Reader
Card reader was punched cards for giving information into the computer.
The computer program which is to be fetched, transformed into punched cards
by the process known as card punching. After punching all the cards, they are
given to the card reader and computer reads the cards one by one. The card
reader converts information represented by the punched holes into electric
pulses.
Webcam
1.7.2 CPU
The task of performing operations like arithmetic and logical operations is
called processing. Central Processing Unit (CPU) takes data and instructions from
the storage unit and makes all sorts of calculations based on user instruction.
CPU is often called as “Brain of Computer”. CPU controls, coordinates and
supervises the operations of the computer.
i. ALU
ii. Control Unit
iii. Register
i.ALU
All calculations are performed in the Arithmetic Logic Unit (ALU) of the
computer. ALU involves two main operations,
Arithmetic Operation
Addition 6+5 = 11
Subtraction 6 – 5 = 1
Multiplication 6 * 5 = 30
Division 6/3 = 2
Logical Operation
The circuits of logic unit enables the CPU to perform logical operations like
AND, OR, XOR, NOT etc., Logical operation involves comparison of two numbers.
Comparison operations are,
iii. Register
Registers are high speed storage areas. Registers store data, instructions,
addresses and intermediate results of processing. It is called as “CPU’s working
memory”. Registers are not referenced by their address, but are directly
accessed and manipulated by the CPU during instruction execution.
ADD R1, R2 Values of register R1 and R2 are added and result stored in
Register R1
1000 ADD B
1003 SUB C
iv. DR Data Register stores the operands and any data needed.
accessed.
vi. MBR Memory Buffer Register temporarily stores data to be sent to memory.
i. Primary Memory
ii. Cache Memory
iii. Secondary Memory
i. Primary Memory
a. RAM
Random Access Memory used to store all data and information in it when
the computer is ON. Content of the RAM are lost when the power is turned OFF,
hence it is called as Volatile Memory. RAM is a temporary memory. It provides
limited storage capacity, due its high cost.
b. ROM
Read Only Memory used to store all data and information permanently.
Content of the ROM are not lost when the power is turned OFF, hence it is called
as Non-Volatile Memory.
Cache memory is used to store data and information that was last
processed in CPU. When processor perform processing, first it searches cache
memory and then in RAM. It increases the speed of computer. Cache memory
is a very high speed semiconductor memory, which can speed up CPU. It acts
as a buffer between the CPU and main memory.
It is used to hold those parts of data and program which are most
frequently used by CPU. The parts of data and programs are transferred from
disk to cache memory by operating system, from where CPU can access them.
CPU directly does not access these memories; instead they are accessed
via input-output routines. Contents of secondary memories are first transferred
to main memory and then CPU can access it.
Some examples of secondary memory are,
Magnetic tape
Hard Disk
Floppy disk
Compact Disc (CD)
Digital Video Disk (DVD)
Universal Serial Bus (USB) or Pen drive etc.,
Following are few of the important output devices, which are used in
Computer Systems:
• Monitors
• Graphic Plotter
• Printer
Important Questions
2 Mark
1. Define computer.
2. List out characteristic of computer.
3. List applications of computer.
4. Define software. Give its types.
5. Differentiate system software and application software.
6. State the difference between analog and digital computer.
7. What is diligence and versatility?
8. What are the basic operations of computer?
9. Define parallel processing.
10.Differentiate general and special purpose computer.
11.What are the three criteria used for classification of computer?
12.What are mainframe computer?
13.For what super computer used for?
14.What is hybrid computer?
15.State the main functions/operations of CPU.
16.What is ALU?
17.Define register. List out its types.
18.Differentiate RAM & ROM.
19.What is cache memory?
20.What is secondary memory? Give example.
16 Mark or 8 Mark
1. Characteristics of computer.
2. Explain in detail about various generation of computer with example.
3. Brief about classification of computer.
4. Explain the classification of computer based on size and capacity.
5. With neat diagram explain in detail about Basic organization of
computer.
CHAPTER 2
NUMBER SYSTEM
2.1 INTRODUCTION
1 0 0 1 0 . 1 0 1 1
Example
(10101.011)2
(1001.10)2
Example
(175.36)8
(12564.57)8
2.1.3 Decimal Number System
Example
(175.896)10
(9564.58)10
Decimal 1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9
Number 0 1 2 3 4 5
Hexadecim
0 1 2 3 4 5 6 7 8 9 A B C D E F
al Number
Example
(175.896)16
(95A4B.5EF) 16
(4A9.2B) 16
BCD System
Binary Coded Decimal (BCD) is used to encode decimal number into binary
number. This is generally accomplished by encoding each digit of the decimal
number into its equivalent binary sequence. Advantage of BCD is fast and
efficient than conversion of pure decimal to binary. BCD system contains various
codes.
Hexadeci
Decimal
mal BCD Code
Number
Number
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
In Excess 3 code, decimal number is converted into 4-bit BCD equivalent by adding 3 to all
the digits of number. It is also known as non-weighted BCD code. It is also represented as “XS3 BCD
Code”.
Adding 3
Decimal
to each BCD Code
Number
digit
0 3 0011
1 4 0100
2 5 0101
3 6 0110
4 7 0111
5 8 1000
6 9 1001
7 10 1010
8 11 1011
9 12 1100
Example:
1. Convert given decimal number 173 into Excess 3 BCD Code.
11+3=4 0100
7 7 + 3 = 10 1010
33+3=6 0110
Answer: 173
010010100110
8 8 + 3 = 11 1011
55+3=8 1000
66+3=9 1001
Answer: 856
101110001001
Numeric data
Non-Numeric data
Almost all the special characters such as +, -, *, /, @, $ etc.
There are three most popular 8-bit BCD codes. They are
a. EBCDIC Code
Hexadeci
Characte Decimal
mal
rs Number
Number
NUL 0 00
STX 2 02
ESC 39 27
SUB 63 3F
[ 74 4A
. 75 4B
< 76 4C
( 77 4D
+ 78 4E
& 80 50
$ 91 5B
* 92 5C
- 96 60
/ 97 61
% 108 6C
? 111 6F
= 126 7E
b. ASCII Code
American Standard Code for Information Interchange (ASCII) is used or the same purpose for
which the EBCDIC code. It is pronounced as ASKEE. This code is more popular, this code can be
implemented by most of the non-IBM computer systems.
Hexadeci
Characte Decimal
mal
rs Number
Number
NUL 0 0
STX 2 2
ESC 27 1B
# 35 23
$ 36 24
% 37 25
& 38 26
* 42 2A
+ 43 2B
/ 47 2F
< 60 3C
= 61 3D
> 62 3E
0-9 48-57 30-39
A-Z 65-90 41-5A
a-z 97-122 61-7A
C. Gray Code
Gray code is another important code that is also used to convert the
decimal number into an 8-bit binary sequence.
1. MSB (Most Significant Bit) of Binary code is same as MSB of Gray code
2. Next MSB of Binary can be determined by adding MSB of Binary with next
MSB of gray coded number.
Example
Gray Code 1 1 0 1 0 0 1 1
Binary Code 1 0
0 1 1 1 0 1
Gray Code 1 1 1 1 0 0 1 0
Binary Code 1 0
1 0 0 0 1 1
1. MSB (Most Significant Bit) of Gray code is same as MSB of Binary code
2. Next MSB of Gray code can be determined by adding subsequent pair bits
of binary number starting from left.
Example
+ + + + + + +
Binary Code 1 ----> 0 ----> 0 ----> 1 ----> 1 ----> 1
----> 0 ----> 1
Gray Code 1 1 0 1 0 0 1 1
+ + + + + + +
Binary Code 1 ----> 0 ----> 1 ----> 0 ----> 0 ----> 0
----> 1 ----> 1
Gray Code 1 1 1 1 0 0 1 0
a. Decimal to Binary
2 147
2 73 -1
2 36 -1
2 18 -0
2 9 -0
2 4 -1
2 2 -0
1 -0
Answer: (147)10 =
(10010011)2
2. Convert decimal number
(62.8125)10 to its Binary equivalent.
2 62
2 31 -0
2 15 -1
2 7 -1
2 3 -1
1 -1
(62)10 = (111110)2
Now,
0.8125 x 2 = 1 . 6250
0.6250 x 1 2 = . 2500
0.2500 x 0 2 = . 5000
0.5000 x 1 2= . 0000
(0.8125)10 = (0.1101)2
Answer (62.8125)10 =
(111110.1101)2
1. (42)10 = (101010)2
2. (135.6875)10 = (10000111.1011)2
3. (59.6825)10 = (111011.1010111)2
4. (36)10 = (100100)2
5. (245)10 = (1110101)2
6. (0.4375)10 = (0.0111)2
7. (59.815)10 = (111011.1101)2
8 1792
8 224 -0
8 28 -0
3 -4
8 154
8 19 -2
2 -3
(154)10 = (232)8
Now,
0.789 x 6 8= . 312
0.312 x 8 = 2 . 496
0.496 x 8 = 3 . 968
0.968 x 8 = 7 . 744
(0.789)10 = (0.6237)2
Answer (154.789)10 =
(232.6237)2
Solve the below problems to practise
1. (225.225)10 = (341.16314)8
2. (359)10 = (547)8
3. (756)10 = (1364)8
4. (399)10 = (617)8
5. (59.815)10 = (73.641)8
16 754
16 47 -2
2 - 15 (F)
16 28
1 - 12 (C)
(28)10 = (1C)8
Now,
0.28125 x 4 16 = . 50000
0.50000 x 8 16 = . 00000
(0.28125)10 = (0.48)2
Answer (28.28125)10 =
(1C.48)2
Solve the below problems to practise
1. (428)10 = (1AC)16
2. (225.225)10 = (E1.399)16
3. (5112)10 = (13F8)16
4. (245)10 = (F5)16
5. (756)10 = (2F4)16
4 3 2 1 0
1 1 1 1 0
0 x 20 =0x1 = 0
1 x 21 = 1 x 2 = 2
1 x 22 =1x4 = 4
1 x 23 = 1 x 8 = 8
1 x 24 = 1 x 16 = 16
-----------
30
------------
4 3 2 1 0 -1 -2 -3
1 0 1 0 1 . 1 1 1
1 x 2 = 1 x 0.125 = 0.125
-3
2. (1111111101.111111)2 = (1021.9562)10
3. (1011.010)2 = (11.25)10
4. (111011.1101)2 = (59.815)10
5. (10101101)2 = (173)10
2 1 0
5 4 0
0 x 80 =0x1 = 0
4 x 81 = 4 x 8 = 32
5 x 82 = 5 x 16 = 320
-----------
352
------------
1 0 -1 -2
2 4 . 3 6
6 x 8-2 =
6 x 0.015 = 0.090
3 x 8-1 = 3 x 0.125 = 0.375
4 x 80 = 4 x 1 = 4
2 x 81 = 2 x 8 = 16
-----------
20.465
------------
2. (6245.14)8 = (3237.1874)10
3. (456)8 = (302)10
4. (127.54)8 = (87.6875)10
5. (325.12)8 = (213.1562)10
D x 160 = 13 x 1 = 13
8 x 161 = 8 x 16 = 128
2 x 162 = 2 x 256 = 512
-----------
653
------------
8 x 16-
3
= 8 x 0.00024
= 0.00195
1 x 16-2 = 1 x 0.0039 =
0.00390
4 x 16-1 = 4 x 0.0625 = 0.2500
B x 160 = 11 x 1 = 11
B x 161 = 11 x 16 = 176
1723.25585
-----------------
Home work Answer (6BB.418)16 =
(1723.25585)10
1. Find the decimal
equivalent of the hexadecimal 2B.C4 (43.7656)10
2. (A2B.D4)16 = (3237.1874)10
3. (D2763)16 = (862051)10
4. (64AC)16 = (25772)10
5. (B14)16 = (2836)10
Other conversions are done using BCD-method. There are six conversions
under this category.
BCD Values to be used in other conversions are given below
Decimal Hexadeci
Octal Code
Number mal Code
0 000 0000
1 001 0001
2 010 0010
3 011 0011
4 100 0100
5 101 0101
6 110 0110
7 111 0111
8 - 1000
9 - 1001
10 (A) - 1010
11 (B) - 1011
12 (C) - 1100
13 (D) - 1101
14 (E) - 1110
15 (F) - 1111
a. Binary to Octal
Steps:
i. Group given binary digit into set of 3 digits starting from LSB (i.e.,
right).
ii. Pad the MSB with zeros if necessary to complete group of 3 digits.
iii. Replace each group by its octal equivalent.
0 1 1 / 1 0 0 / 1 0 1
3 4 5
1 1 1 / 1 0 1 / 1 0 0 . 0 0 0 / 1 0 0
7 5 4 0
4
Answer (111101100.0001)2 =
(754.04)8
Home work
1. (10111001100.1101011)2 = (2714.654)8
2. (1111111101.111111)2 = (1775.77)8
3. (1110.1011)2 = (16.54)8
b. Binary to Hexadecimal
Steps:
iv. Group given binary digit into set of 4 digits starting from LSB (i.e.,
right).
v. Pad the MSB with zeros if necessary to complete group of 4 digits.
vi. Replace each group by its hexadecimal equivalent.
1 1 1 0 / 0 1 0 1
E 5
0 0 0 1 / 1 0 0 1 / 1 1 0 1 . 1 1 0 1 / 0 1 0 0
1 9 D . D 4
= (D3)16
2. (1111111101.111111)2 = (3FD.FC)16
3. (1101001101110111)2 = (D377)16
c. Octal to Binary
To convert given octal number to binary number, write the corresponding
group of 3 digits BCD code for each octal digit.
6 3 4 7
Answer (6347)8 =
(110011100111)2
2. Convert given octal number (375.16)8 to its binary equivalent.
3 7 5 . 1 6
Answer (375.16)8 =
(011111101.001110)2
Home work
1. (654)8 = (110101100)2
2. (561)8 = (101110001)2
3. (231)8 = (010011001)2
d. Hexadecimal to Binary
5 C 8
4 3 . 1 0 A B
Answer (43.10AB)16 =
(01000011.0001000010101011)2
Home work
3. (FAC)16 = (111110101100)2
4. (2AC)16 = (001010101100)2
5. (5AF)16 = (010110101111)2
e. Octal to Hexadecimal
1. Octal to binary
2. Binary to Hexadecimal
Note: Procedure for above two had been solved in previous categories
2 3 2 7
(2327)8 = (010011010111)2
Step 2: Now convert obtained binary to hexadecimal
0 1 0 0/1 1 0 1/0 1 1 1
4 D 7
(010011010111)2 = (4D7)16
Final answer is
Answer (2327)8 = (4D7)16
4 6 3 . 5 2
100 110
011 101 010
(463.52)8 =
(100110011.101010)2
0 0 0 1 / 0 0 1 1 / 0 0 1 1 . 1 0 1 0 / 1 0 0 0
1 3 3 . A 8
(100110011.101010)2 =
(133.A8)16
Final answer is
Answer (463.52)8 = (133.A8)16
Home work
1. (7521)8 = (?)16
2. (235.21)8 = (?)16
f. Hexadecimal to Octal
1. Hexadecimal to binary
2. Binary to Octal
Note: Procedure for above two had been solved in previous categories
(A2DE)16 =
(1010001011011110)2
0 0 1 / 0 1 0 / 0 0 1 / 0 1 1 / 0 1 1 / 1 1 0
1 2 1 3 3
6
(1010001011011110)2 =
(121336)8
Final answer is
Answer (A2DE)16 = (121336)8
A C 5 . 4 D
(101011000101.01001101)2 =
(5305.232)8
Final answer is
Answer (AC5.4D)16 = (5305.232)8
Home work
2. (2C6B.F06)16 = (26153.7406)8
3. (2B6)16 = (1266)8
(01110111101)2
(3675)8
One’s complement
Two’s complement
Binary addition
Binary subtraction
Binary multiplication
Binary division
Example
1’s complement of
Binary Number
binary number
10001 01110
101001 010110
111000 000111
Example
0+0=0
1+0=1
0+1=1
1 + 1 =0 and
carry = 1
1+1+1=1 and
carry = 1
Example
1 1 Carry
1 0 1 1
+ 1 0 1 1
--------------------------------
1 0 1 1 0
--------------------------------
1 1 Carry
0 0 0 1 1 0 1 0
+ 0 0 0 0 1 1 0 0
-----------------------------------------------------------------------
0 0 1 0 0 1 1 0
------------------------------------------------------------------------
0-0=0
1-0=1
0-1=1 and
borrow=1
1 - 1 =0
Example
0 10 Borrow
0 0 1 0 0 1 0 1
-0 0 0 1 0 0 0 1
-----------------------------------------------------------------------
0 0 0 1 0 1 0 0
-----------------------------------------------------------------------
0 10 0 10 1
10 Borrow
0 0 1 1 0 0 1 1
-0 0 0 1 0 1 1 0
-----------------------------------------------------------------------
0 0 0 1 1 1 0 1
------------------------------------------------------------------------
b. Method II
Example
1 1 1 1 1 1 Carry
0 0 1 0 0 1 0 1
+ 1 1 1 0 1 1 1 1
-----------------------------------------------------------------------
1 0 0 0 1 0 1 0 0
Discard ------------------------------------------------------------------------
Example
1 1 1 Carry
0 0 1 1 0 0 1 1
+ 1 1 1 0 1 0 1 0
-----------------------------------------------------------------------
1 0 0 0 1 1 1 0 1
Discard ------------------------------------------------------------------------
Home work
Example
1 0 1 1 x 1 1 1
--------------------------------------------------------------------------
1 1 1 1
1 0 1 1
1 0 1 1
1 0 1 1
--------------------------------------------------------
1 0 0 1 1 0 1
--------------------------------------------------------
1 0 1 0 0 1 x 1 1 0
------------------------------------------------------------------------------------------
0 0 0 0 0 0
1 0 1 0 0 1
1 0 1 0 0 1
-----------------------------------------------------------------------
1 1 1 1 0 1 1 0
-----------------------------------------------------------------------
Example
1. Divide binary numbers 1011 ÷ 11
1 1 Quotient
11 1 0 1 1
1 1
------------------------
1 0 1
1 1
-----------------------
1 0 Remainder
-----------------------
Answer 1011 ÷ 11 = 11
1 1 0 1 1 Quotient
101 0 1 1 10
1 00 00 1 1 1
- 10 1
-----------------
0 0 1 10
- 1 0 1
--------- ----
0 01 11
1 01
--------- ---
0 10 1
10 1
-------------
0
------------
Answer 10000111 ÷ 101 =
11011
Home work
2. 1001 ÷ 11 11
2.4 NEED FOR LOGICAL ANALYSIS AND THINKING
Logical thinking is essential for every programmer. The students, who are
into programming and learning it, should capable to think logically but basically
most of the beginners suffer a lot to think logical and improve logical thinking
skills.
Logic is a small code snippet or the part of the program which consist of set of
instruction to solve the given problem. Logic of the program is the actual
statements which are to be executed by the computer in order to solve the
problem. The logic for solving a problem is developed using set of instructions
and embedded them in a program by following the rules of writing a program
Identify the
problem
To produce an effective result, programmer must take care of each and every
step in sequential order.
1. Instruction to be performed.
2. Sequence in which those instructions are to be performed.
3. Data required to perform those instructions.
To solve the problem using the computer, the following steps are
followed.
There are three ways to represent logical steps for finding the solution to a
given problem. They are
1. Algorithm
2. Flowchart
3. Pseudo code
2.5.1 ALGORITHM
Characteristics of an algorithm
Qualities of an algorithm
Example
Step 1: Start
Step 2: Read 2-numbers A, B.
Step 5: Stop.
Step 1: Start
Step 7: Stop.
Step 1: Start
Step 6: Stop.
Step 1: Start
Step 5: Stop.
Step 1: Start
Step 2: Read a number “n”
Step 4: Set a loop to find the factorial of the given number “n” using
formula
fact=fact*i.
Step 6: Stop.
2.5.2 FLOWCHART
Flowchart Symbols
A flowchart is drawn using different kinds of symbols. A symbol used in a flowchart is for a
specific purpose. Their shapes and functions are predefined in nature.
Advantage / Benefits
1. A flowchart helps to clarify how things are currently working and how they
are improved.
2. It helps to remove repeated and misplaced steps.
3. It helps in monitoring important areas, data collections etc for increase in
efficiency.
Limitations / Disadvantage
In sequence control structure, the steps are executed in linear order one
after the other. Flow of the control is sequential in order from top to bottom.
Example
Start
Read A, B
Flow of given
flowchart is
C=A+B sequential
Print C
Start
b. Selection control structure
Example
Flowchart for finding greatest of 2-numbers
Start
Read A, B
No Print “B is
If
A> great”
B
Yes
Print “A is
great”
Stop
Example
Read n
Fals
for e
(i=1;i<n;i+
+) Given true
statement is True
Read n Executed
repeatedly values
Until for loop fails
Sum of all
values
Start
Average =
sum/n
Read
A,B,C
Print sum
and
average
Yes No
If If
A>
Stop A>
B C
No Yes
No
If
B>
Flowchart to Print A Print C
C
find greatest
of 3-numbers Yes
Print B
Print C
Stop
Practise flowchart for following questions
Example
READ A, B
COMPUTE C by adding A with B
PRINT C
STOP
READ n
FOR (i=0;i<n;i++)
READ all inputs a[i]
END FOR
COMPUTE SUM by adding all values
CALCULATE AVG by dividing SUM by n
DISPLAY SUM and AVG
STOP
READ A,B
IF (A>B)
DISPLAY “A is great”
ELSE
PRINT :B is great”
STOP
READ A,B,C
IF (A>B)
IF (A>C)
DISPLAY “A is great”
ELSE IF (B>C)
PRINT “B is great”
ELSE
PRINT “C is great”
STOP
SET sum=0
FOR (i=0;i<=100;i++)
CALCULATE sum=sum+i
EN FOR
PRINT sum
STOP
READ n
INITIALIZE i=0
SET sum=0
DO WHILE (i<n)
COMPUTE sum=sum+i
i =i+2
END DO
WRITE sum
STOP
READ radius
COMPUTE area=3.14*r*r
PRINT area
STOP
Important Question
2 marks
1. What is an algorithm?
2. What is flowchart? State its advantage.
3. What is pseudo code?
4. State advantage and disadvantage of an algorithm.
5. Differentiate program and algorithm.
6. List benefits and limitations of pseudo code.
7. State the benefits of drawing flowchart.
8. What are limitations of flowchart?
9. Write down the steps involved in writing a program.
10.List out characteristics of good program.
11.What are the characteristics of good algorithm?
12.Give basic symbols used in flowchart with its purposes.
13.List out design structure of flowchart.
14.Algorithm or pseudo code for any program.
15.Draw flowchart to find greatest of 3 numbers.
Detail
1. Draw and explain various symbols of flowchart and draw the flowchart to
add n-elements.