CP Text
CP Text
Fundamentals and
Programming in
— Reema Thareja |
Computer
Fundamentals and
Programming in
SECOND EDITION
Reema Thareja
Assistant Professor
Department of Computer Science
Shyama Prasad Mukherji College for Women
University of Dethi
OXFORD
UNIVERSITY PRESS
OXFORD
UNIVERSITY PRESS
Published in India by
Oxford University Press
YMCA Library Building. 1 Jai Singh Road, New Delhi 110001, India
© Oxford University
Press 2012. 2016
poe ee
a retrieval system, or transmitted, in any form or by any means, without the
i ifOxford University Press, ited
ISBN-13: 978-0-19-946373-2
ISBN-10; 0-19-946373-5
Keys such as Shift, Ctrl, and Alt are called modifier keys
because they are used to modify the normal function of a
key. For example, Shift + character (lowercase) makes the
Notes and Programming Tips computer display the character in upper case.
Notes highlight important terms and concepts,
and programming tips educate the readers about
common programming errors and how to avoid Programming
Tip:
Strings cannot be
them manipulated with
arithmetic or other
operators available in
C boundaries.
POINTS TO REMEMBER
GUDSSARY
Glossary eee pa nee at rtsayat oeet
cae mereSta
meet owe sree Hataati teat
Includes a list of key terms along with their definitions Come mate nage Snr ene
ane mae owtee© ot paeny Oe
for a quick recapitulation of important terms learned ee
ee anadieaddeed
in all chapters fe ees ore eS
Cans met capes The mee oteat
the Book
CASE STUDY 1: Chapters
9and10
a attire Case Studies
Select chapters on C include case studies that
CASE STUDY 2: Chapter 12
show how C can be used to create programs
demonstrating real-life applications
.4 +
» =
Sa. to Objective
tions Objective Questions
Includes comprehensive exercises at the end of each
chapter to facilitate revision—Answers to these
questions are provided in Appendix F at the end of
the book
EXERCISES
Exercises
Includes plenty of program code-related programs
at the end of relevant chapters, which require the
readers to find the output of a given code, the
functionality of a given loop, or errors in a given
program code
Companion Online Resources
SOOKE
Visit india.oup.com/ores/9780199463732 to access
both teaching and learning solutions online.
Online Resources
The following resources are available to support the
faculty and students using this text:
For Faculty
* PowerPoint presentations
* Solutions manual
* Projects
For Students
* Multiple-choice Questions
* Model Question Papers
* Codes of chapter-wise programming examples
Step 9:Confirmation
© Youwil receivea
confemation omyour
‘Step 4:ViewResources gray = =
© Chik on"Viewat Fear
resources* Step 20;Visitusagain
oa, © Goto indiacup-com
aS © Sign in withOuferdiO
Step 11: Visityourlicensed products Step 12:Download Resources
* Goto “Resources” section © Git onthetitle
. View orine resources
— Resources
© Select resource type
=—-- -
© Oownioad the resource you require
Preface to the Second Edition
Information technology (IT) is the buzzword in the 21st century. It has revolutionized the way we think and irreversibly
changed our everyday existence. Computers form the backbone of information technology affecting all aspects of our
lives, They are not only used for general computing but also for performing tasks such as booking railway and airline
tickets, designing a building, training a player, and practicing landing of an airplane. The use of computers has become so
widespread that almost all electrical and electronic devices such as washing machines and air conditioners have a small
embedded computer within them. Even the smartphones are connected to the Internet.
Learning computers is no longer meant only for students pursuing 4 career in engineering and technology, but is also
mandatory for students of other professions such as journalism, nursing, archacology, and construction and management.
Therefore, a basic knowledge of computers helps one to be more productive and self-sufficient.
Moreover, C is considered to be the mother of all moderm-day computer languages. Almost all popular cross-platform
programming languages and scripting languages, such as C++, Java, Python, Objective-C, Perl, Ruby, PHP, Lua, and
Bash, are implemented in C and borrow syntaxes and functions heavily from C. In the programming language popularity
website, C tops the list followed by C++ and Java.
Thus, knowledge of C provides a solid foundation to learn advanced programming skills such as object-oriented
programming, event-driven programming, multi-thread programming. real-time programming, embedded programming,
network programming, parallel programming, other programming languages, and new and emerging computing
paradigms such as grid-computing and cloud computing.
PEDAGOGICAL FEATURES
The following are the salient features of the book:
Comprehensive coverage Provides comprehensive coverage of important topics ranging from the basics of computers
to C programming and important data structures
Case studies Includes case studies at the end of select chapters on C, which provide practical orientation to the concepts
discussed in the respective chapters.
Complete program codes Contains plenty of program codes that are thoroughly tested and compiled to support the
text
Practical orientation Provides numerous solved examples and chapter-end exercises in the form of objective-type
questions, review exercises, and programming problems that enable the students to check their understanding of the
concepts
Glossary Includes a list of key terms at the end of each chapter that facilitates revision of important topics learned
Tips and Notes Includes programming tips that educate readers about common programming errors and how to avoid
them and notes that highlight important terms and concepts in between the text as sidebars for a quick recapitulation,
Chapter 1 To provide readers a perspective of how computers evolved over the last century, this chapter presents a
section on history of computers, which gives a timeline of the developments in computing technology. The section on
applications of computers covers new applications.
it Preface to the Second Edition
3 The section on secondary storage devices includes latest devices such as Blu-ray disks and external hard
disks, The chapter now also provides section on processor architecture, which focuses on the different components of a
processor, and types of processors.
Chapter 4 This chapter includes new examples to demonstrate the addition and subtraction of hexadecimal and octal
numbers. In addition, the chapter covers codes such as Unicode and 8421 and 2421 BCD codes. The sections on logic
gates and universal gates have been moved to Chapter 5.
Chapter 5 This is a new chapter, which focuses on logic gates that form the basic building blocks of a digital circuit,
and discuses Boolean algebra, which is used to express the output of any circuit implemented using logic gates.
Chapter 6 This chapter strengthens discussion on operating systems by briefly explaining the command interpretation
module of an operating system and CLI vs GUI interface. It discusses the features of Windows 8 and Windows 10 along
with mobile operating systems, In addition, it includes a section outlining the differences between customized and public
domain software.
Chapter 7 To familiarize readers with how applications communicate over a network, this chapter provides a brief
overview of two reference models—OSI! model and TCP/IP model. In addition, it discusses Internet-related concepts
such as IP address, URL, and domain name system (DNS).
Chapter 8 \n order to make the text more coherent, this chapter has been restructured to focus on the program designing
tools that aid in the development of efficient programs. The section on programming languages has been shifted to
chapter 6.
Chapter 9 This chapter includes an annexure, which shows the steps to compile and execute C programs on both Unix/
Linux and Ubuntu platforms,
Chapter 12 This chapter adds a program showing the array representation of sparse matrices. Similarly, it includes a
program to find whether a matrix is symmetric or not.
Chapter 14 \t includes a program to illustrate the dangling pointer problem.
Chapter 15 \t presents three different ways to find the size of a structure, All these different methods have been
exemplified through program codes.
ACKNOWLEDGEMENTS
1 would like to gratefully acknowledge the feedback and suggestions provided by various faculty members for the
improvement of the book. | am obliged to the editorial team at Oxford University Press India for alltheir support towards
revising this book. Suggestions for improving the presentation and contents can be sent to the publishers through their
website www.india.oup.com or to me at reemathareja@ gmail.com.
Reema Thareja
Preface to the First Edition
Computers are so widely used in our day-to-day lives that imagining a life without them has become almost impossible.
They are not only used by professionals but also by children for interactively learning lessons, playing games, and doing
their homework. Applications of the computer and its users are increasing by the day.
Learning computer fundamentals is a stepping stone to having an insight into how these machines work. Once the
reader is aware of the basic terminology that is commonly used in computer science, he/she can then go on to develop
useful computer programs that may help solve a user's problems.
Since computers cannot understand human languages, special programming languages are designed for this purpose.
C is one such programming language. Being the most popular programming language, it is used in several different
software platforms such as system software and application software. A few other programming languages such as C++
and JAVA are also based on C. Hence, mastering the C language is a prerequisite for learning such languages.
ACKNOWLEDGEMENTS
The writing of this textbook was a mammoth task for which a lot of help was required from many people. Fortunately, |
have had the fine support of my family, friends, and fellow members of the teaching staff at the Institute of Information
Technology and Management, Delhi.
My special thanks would always go to my father Shri Janak Raj Thareja, my mother Smt. Usha Thareja, my brother
Pallay, and sisters Kimi and Rashi who were a source of inspiration and divine blessings for me. | am especially thankful
to my son Goransh who has been very patient and cooperative in letting me realize my dreams, My sincere thanks go to
my uncle, Mr B.L. Theraja, for his inspiration and guidance in writing this book.
Finally, | would like to acknowledge the technical assistance provided to me by Ed. Udit Chopra, who helped me in
designing and testing the numerous program codes provided in the book.
Last but not least, my acknowledgements will remain incomplete if | do not thank the editorial team at Oxford
University Press, India, for supporting me wholeheartedly during the publication of my books over the past few years.
Reema Thareja
Brief Contents
Features of the Book iv
Companion Online Resources vi
Preface to the Second Edition vii
Preface to the First Edition x
Detailed Contents xii
12.12 Applications of Arrays 308 14,10 Difference Between Array Name and
Case Study 2: Chapter 12. 313 Pointer 360
14.11 Pointers and Strings 360
13 Strings 317 14.12 Arrays of Pointers 364
13.1 Introduction 3/7
14.13 Pointers and 2D Arrays 365
13.1.1 Reading Strings 318
14.14 Pointers and 3D Arrays 367
13.1.2 Writing Strings 319
14.15 Function Pointers 368
13.13 Summary of Functions Used to Read
14.15.1 Initializing a Function Pointer 368
and Write Characters 320
1415.2 Calling a Function Using a Function
13.2 Suppressing Input 32/
Pointer 368
13.2.1 Using a Scanset 321
14,15.3 Comparing Function Pointers 369
13.3 String Taxonomy 322
14.15.4 Passing a Function Pointeras an
13.4 Operations on Strings 322
Argument to a Function 369
13.4.1 Finding the Length of a
14.16 Array of Function Pointers 369
String 323
14.17 Pointers to Pointers 370
13.4.2 Converting Characters of a String into
14.18 Memory Allocation in C Programs 370
Upper Case 323
14.19 Memory Usage 370
13.4.3 Converting Characters of a String Into
14.20 Dynamic Memory Allocation 37/
Lower Case 324
14.20.1 Memory Allocations Process 371
13.4.4 Concatenating Two Strings to Form a
14.20.2 Allocating a Block of Memory 371
New String 324
14.20.3 Releasing the Used Space 372
13.4.5 Appending a String to Another
String 325
14.204 To Alter the Size ofAllocated
Memory 373
13.4.6 Comparing Two Strings 326
14.21 Drawbacks of Pointers 374
13.4.7 Reversing a String 325
Annexure 3 382
13.4.8 Extracting a Substring from
Left 327
Case Study 3: Chapters 13 and 14 384
13.4.9 Extracting a Substring from Right of 15 Structure, Union, and Enumerated
the String 328 Data Type 386
13.4.10 Extracting a Substring from the 15.1 Introduction 386
Middle of a String 328 15.1.1 Structure Declaration 386
13.4.11 Inserting a String in Another 15.1.2 Typedef Declarations 387
String 329 15.1.3 Initialization of Structures 388
13.4.12 Indexing 330 15.1.4 Accessing the Members ofa
13.4.13 Deleting a String from the Main Structure 388
String 330 15.1.5 Copying and Comparing
13.4.14 Replacing a Pattern with Another Structures 389
Pattern in a String 331 15.1.6 Finding the Size of a Structure 389
13.5 Miscellaneous String and Character 15.2 Nested Structures 392
Functions 33/ 15.3 Arrays of Structures 393
13.5.1 Character Manipulation 15.4 Structures and Functions 395
Functions 331 15.4.1 Passing Individual Members 395
13.5.2 String Manipulation Functions 332 15.4.2 Passing the Entire Structure 395
13.6 Arrays of Strings 337 15.4.3 Passing Structures Through
Pointers 398
M4 Pointers 347
15.5 Self-referential Structures 402
14.1 Understanding the Computer's
15.6 Unions 402
Memory 347
15.6.1 Declaring a Union 402
14.2 Introduction to Pointers 348
15.6.2 Accessing a Member of a
14.3 Declaring Pointer Variables 348
Union 403
14.4 Pointer Expressions and Pointer
15.6.3 Initializing Unions 403
Arithmetic 350
15.7 Arrays of Union Variables 404
14.5 Null Pointers 354
15.8 Unions Inside Structures 404
14.6 Generic Pointers 354
15.9 Structures Inside Unions 404
14.7 Passing Arguments to Function Using
15.10 Enumerated Data Type 405
Pointers 354
15.101 enum Variables 406
14.8 Pointers and Arrays 358
15.10.2 Using the Typedef Keyword 406
14.9 Passing an Array to a Function 359
Detailed Contents eit
1 Introduction to Computers
6 Computer Software
FA Computer Networks and the Internet
TAKEAWAYS
* Characteristicsof computers
* Digital computers
* Stored program concept
and say that the age of the student is 23 years, then the
COMPUTER outcome is information,
These days, computers have become a crucial part of
A computer, in simple terms, can be defined as an our everyday lives, and we need computers just like we
electronic device that is designed to accept data, perform need televisions, telephones, or other electronic devices at
the required mathematical and logical operations at high home. Computers are basically meant to solve problems
speed, and output the result, quickly and accurately, The important characteristics
We all have seen computers in our homes, schools, and of a computer (refer to Figure 1.1) are discussed in the
colleges. In fact, in today’s scenario, we find computers in following text.
most aspects of our duily lives. For some of us, it is hard to
even imagine a world without them,
In the past, computers were extremely large in size
and often required an entire room for installation. These
computers consumed enormous amounts of power and
were too expensive to be used for commercial applications.
Therefore, they were used only for limited tasks, such
as computing trajectories for astronomical or military
applications, However, with technological advancements,
the size of computers became smaller and their energy
requirements reduced immensely. This opened the way for
adoption of computers for commercial purposes.
These days, computers have become so prevalent in
the market that all interactive devices such as cellular
phones, global positioning system (GPS) units, portable
organizers, automated teller machines (ATMs), and gas
pumps, work with computers.
Figure 1.1 Characteristics of computers
id the incorrect data/program is responsible. This clearly computers also reduces manpower requirements and leads
means that the output generated by a computer depends on toan elegant and efficient way of performing various tasks.
the given instructions and input data, If the input data is Hence, computers save time, energy, and money, When
wrong, then the output will also be erroneous. In computer compared to other systems, computers can do more work
terminology, this is known as garbage-in, garbage-out in lesser time. For example, using the conventional postal
(GIGO). system to send an important document takes at least two to
three days, whereas the same information when sent using
Automation Besides being very fast and accurate, the Internet (e-mail) will be delivered instantaneously,
computers are automatable devices that can perform a
task without any user intervention. The user just needs to
assign the task to the computer, after which it automati- STORED PROGRAM CONCEPT
cally controls different devices attached to it and executes
the program instructions. All digital computers are based on the principle of stored
Diligence Unlike humans, computers never get tired of a program concept,which was introduced by Sir John von
repetitive task. It can continually work for hours without Neumann in the late 1940s. The following are the key
creating errors. Even if a large number of executions need characteristic features of this concept:
to be executed, each and every execution requires the same * Before any data is processed, instructions are read into
duration, and is executed with the same accuracy. memory.
Versatile Versatility is the quality of being flexible. Today, + Instructions are stored in the computer's memory for
execution.
computers are used in our daily life in different fields. For
* Instructions are stored in binary form (using binary
example, they are used as personal computers (PCs) for numbers—only Os and Is),
home use, for business-oriented tasks, weather forecasting,
+ Processing starts with the first instruction in the program,
space exploration, teaching, railways, banking, medicine,
which is copied into a control unit circuit. The control
and so on, indicating that computers can perform different unit executes the instructions.
tasks simultaneously. On the PC that you use at home,
you may play a game, compose and send e-mails, listen
+ Instructions written by the users are performed
sequentially until there is a break in the current flow.
to music, etc. Therefore, computers are versatile devices
as they can perform multiple tasks of different nature at * Input/Output and processing operations are performed
simultaneously, While data is being read/written, the
the same time.
central processing unit (CPU) executes another program
Memory Similar to humans, computers also have in the memory that is ready for execution,
memory. Just the way we cannot store everything in our
memory and need secondary media, such as a notebook,
to record certain important things, computers also have
internal or primary memory (storage space) as well as
external or secondary memory. While the internal memory
of computers is very expensive and limited in size, the
secondary storage is cheaper and of bigger capacity.
The computer stores a large amount of data and John W. Mauchly, an American physicist, and J.
programs in the secondary storage space. The stored Presper Eckert, an American engineer, further contributed
data and programs can be retrieved and used whenever to the stored program concept to make digital computers
required, Secondary memory is the key for data storage. much more flexible and powerful. As a result, engineers
Some examples of secondary devices include floppy disks, in England built the first stored-program computer,
optical disks (CDs and DVDs), hard disk drives (HDDs), Manchester Mark I, in the year 1949, They were shortly
and pen drives. followed by the Americans who designed EDVAC in the
When data and programs have to be used, they are very same year.
copied from the secondary memory into the internal Today, a CPU chip can handle billions of instructions
memory, often known as random access memory (RAM). per second. It executes instructions provided both the data
The concept of computer memory is discussed in detail in and instructions are valid. In case either one of them or
Chapter 3. both are not valid, the computer stops the processing of
instructions.
No 1Q Although the trend today is to make computers
intelligent by inducing artificial intelligence (AI) in them,
they still do not have any decision-making abilities of their
1.3.1 Types of Stored Program Computers
own. They need guidance to perform various tasks. A computer with a Von Neumann architecture stores data
Economical Today, computers are considered as short- and instructions in the same memory. There is a serial
term investments for achieving long-term gains. Using machine in which data and instructions are selected one
Introduction to Computers
®)
peaches address
Read/Write Data
Figure 1.2 Von Neumann architecture (a) Shared memory for instructions and data (b) Separate
memories for instructions and data
at a time. Data and instructions are transferred to and China. It was used by the Babylonians even in 300 BC and
from memory through a shared data bus. Since there is a is still in use today (in the Far East).
single bus to carry data and instructions, process execution
1822: English mathematician Charles Babbage designed
becomes slower.
a steam-driven calculating machine that could compute
Later Harvard University proposed a stored program
tables of numbers. Though the project failed as he could
concept in which there was a separate memory to store
not complete the construction of the engine, it laid the
data and instructions, Instructions are selected serially
foundation for the first computer.
from the instruction memory and executed in the processor.
When an instruction needs data, it is selected from the data 1890: Herman Hollerith, an American inventor, designed
memory, Since there are separate memories, execution a punched card system to calculate the 1880 census,
becomes faster, The system completed the task in three years saving the
US government $5 million. Later Herman established a
company that we today know as IBM.
HISTORY OF COMPUTERS 1936: British mathematician Alan Turing introduced
4 universal machine called the Turing machine capable
Early computers were designed not for entertainment but of computing anything that is computuble, The central
for solving number-crunching problems. These computers concept of the modern computer is based on this machine.
were punch-card based computers that took up entire rooms,
1941: John Vincent Atanasoff, a Bulgarian-American
‘Today, our smurtphones have much more computing power
physicist, and his graduate student, Clifford Berry, at lowa
than that was available in those early computers,
State College designed Atanasoff—Berry computer (ABC)
In this section, we will read about history ofcomputers
that could solve 29 equations simultaneously. It was the
way back from the invention of abacus and take a look at
first time a computer could store information in its main
the remarkable achievements in computing technology till
memory.
the current time,
1943-1944: John W. Mauchly and J. Presper Eckert
Timeline of Developments built the Electronic Numerical Integrator and Calculator
(ENIAC), which is considered as the grandfather of digital
300 BC: The abacus was an early aid for mathematical computers. It filled a 20 x 40 feet room and had 18,000
computations and was designed to aid human’s memory vacuum tubes.
while performing calculations. A skilled abacus operator
can add and subtract with the same speed asthat ofa person 1946: Mauchly and Presper designed the UNIVAC,
performing the same calculation using a hand calculator. which was the first commercial computer for business and
The invention of abacus is often wrongly attributed to government applications.
86 Computer Fundamentals and Programming in C
: William Shockley, John Bardeen, and Walter 1986: Compaq introduced Deskpro 386 in the market,
Brattain of Bell Laboratories invented the transistor. Soon which was a 32-bit architecture machine that provides
vacuum tubes in computers were replaced by transistors. speed comparable to mainframes.
1953: Grace Hopper developed the first computer 1990: Tim Berners-Lee invented World Wide Web with
language COBOL. HTML as its publishing language.
1954: The FORTRAN programming language was 1993: The Pentium microprocessor introduced the use of
developed. graphics and music on PCs.
1958: Jack Kilby of Texas Instruments and Robert 1994: PC games became popular.
Noyce at Fairchild Semiconductor Corporation separately
1996: Sergey Brin and Larry Page developed the Google
invented integrated circuit, which is commonly known as search engine at Stanford University.
the computer chip.
1999: The term Wi-Fi was introduced when users started
1964: Douglas Engelbart developed a prototype of the
connecting to the Internet without wires.
modern computer, with a mouse and a graphical user
interface (GUI). This was a remarkable achievement 2001: Apple introduced Mac OS X operating system,
as it shifted computers from a specialized machine for which had protected memory architecture and pre-emptive
scientists and mathematicians to general public. multi-tasking, among other benefits, To stay competitive,
1969: Unix operating system was developed at Bell Labs. Microsoft launched Windows XP.
It was written in the C programming language and was 2003: The first 64-bit processor, AMD's Athlon 64, was
designed to be portable across multiple platforms, Soon it brought into the consumer market,
became the operating system of choice among mainframes
at large companies and government entities. 2004: Mozilla released Firefox 1.0 and in the same year
Facebook, a social networking site, was launched.
1970: DRAM chip was introduced by Intel.
2005: YouTube, a video sharing service, was launched. In
1971: Alan Shugart with his team in IBM invented the same year, Google acquired Android, a Linux-based
the floppy disk which allowed data to be shared among mobile phone operating system.
computers.
2006: Apple introduced MacBook Pro, its first Intel-
1973: Robert Metcalfe, a research member at Xerox, based, dual-core mobile computer.
developed Ethernet for connecting multiple computers
and other hardware. 2007: Apple released iPhone, which brought many
computer functions in the smartphone.
1974-1977: Personal computers started =becoming
popular, 2009: Microsoft launched Windows 7 in which users
1975: Paul Allen and Bill Gates started writing software for could pin applications to the taskbar.
the Altair 8800 using the new BASIC language. On Apnil 4. 2010: Apple launched iPad, which revived the tablet
they both formed their own software company, Microsoft. computer segment.
1976: Steve Jobs and Steve Wozniak started Apple 2011: Google introduced Chromebook, a laptop that runs
Computers and developed Apple I, the first computer with on the Google Chrome operating system.
a single-circuit board.
2015: Apple released the Apple Watch. In the same year,
1977: Apple Il was launched that offered colour graphics Microsoft launched Windows 10.
and incorporated an audio cassette drive for storage.
After reading these interesting developments in
1978: WordStar, a word processor application, was computing technology, let us also understand the evolution
released by MicroPro International. of computers through different generations.
1979: VisiCalc. the first computerized spreadsheet
program for personal computers, was unveiled. First Generation (1942-1955)
1981: The first IBM personal computer was introduced Hardware Technology First generation computers were
that used Microsoft's MS-DOS operating system. The manufactured using thousands of vacuum tubes (see
term PC was popularized. Figure 1.3); a vacuum tube is a device made of fragile glass.
1983: The first laptop was introduced. Moreover, Apple Memory Electromagnetic relay was used as primary
introduced Lisa as the first personal computer with a GUI memory and punched cards were used to store data and
with drop-down menus and icons. instructions.
1985: Microsoft announced Windows as a new operating Software Programming was done in machine
system, or assembly language.
Introduction to Computers Cc
Used for Scientific applications * They consumed 1/10th the power consumed by
generation computers
Examples ENIAC, EDVAC, EDSAC, UNIVAC 1, IBM 701 * Bulky in size and required a complete room for its
Highlights installation
* They were the fastest calculating device of those times + Dissipated less heat than first generation computers but
still required air-conditioned rooms
* Computers were too bulky and required a complete
* Costly
room for storage
* Highly unreliable as vacuum tubes emitted a large * Difficult to use
amount of heat and burnt frequently
Required air-conditioned rooms for installation
Costly
Difficult to use
Required constant’ maintenance because vacuum
tubes used filaments that had limited life time. até
Therefore, these computers were prone to frequent
hardware failures
o*
Bulky in size and required a complete room for Highlights Faster, smaller, cheaper, powerful, reliable,
installation and easier to use than the previous generation computers
* Dissipated less heat than second generation computers
but still required air-conditioned rooms
* Costly
* Easier to use and upgrade
ts
on asingle
LSI circuits contained 30,000 componen chip
Memory Semiconductor memory is used as primary
and VLSI technology had about one million electronic memory: large capacity magnetic disks are used as built-in
componen ts
on asingle chip. secondary memory. Magnetic tapes and floppy disks were
used as portable storage devices, which have now been
Memory Semiconductor memory was used as primary replaced by optical disks and USB flash drives.
memory, large capacity magnetic disks were used as built-
Software Technology Programming is done in high-level
in secondary memory. Magnetic tapes and floppy disks
programming languages such as Java, Python, and C#
were used as portable storage devices Graphical User Interface (GUI)-based operating systems
Software Technology Programming was done in such as Windows, Unix, Linux, Ubuntu, and Apple Mac
high level programming language such as C and C++ are being used. These operating systems are more powerful
Graphical User Interface (GUI) based operating system and user friendly than the ones available in the previous
(c.g. Windows) was introduced. It had icons and menus generations.
among other features to allow computers to be used as Used for Scientific, commercial, interactive online,
a general purpose machine by all users. UNIX was also
multimedia (graphics, audio, video), and network applications
introduced as an open source operating system. Apple Mac
OS and MS DOS were also released during this period. All Examples 1BM_ notebooks, Pentium PCs, SUM
these operating systems had multi-processing and multi- workstations, IBM SP/2, Param supercomputer
programming capabilities, Highlights
Used for Scientific, commercial. interactive online, and * Faster, smaller, cheaper, powerful, reliable, and easier to
network applications use than the previous generation computers
Examples 1BM PC. Apple Il, TRS-80, VAX 9000, CRAY- * Speed of microprocessors and the size of memory are
1, CRAY-2, CRAY-X/MP growing rapidly
Introduction to Computers
ce
(0 )
* High-end features available on mainframe computers units, etc. Some examples of supercomputers are CRAY=Ty
in the fourth generation are now available on the CRAY-2, Control Data CYBER 205, and ETA A-10,
mucroprocessors
* They consume less power than computers of prior 1.5.2 Mainframe Computers
generations
* Air-conditioned rooms required for mainframes and Mainframe computers are large-scale computers (but
supercomputers but not for microprocessors smaller than supercomputers). These are very expensive and
need a very large clean room with air conditioning, thereby
making them very costly to deploy. As with supercomputers,
mainframes can also support multiple processors. For
example, the IBM $/390 mainframe can support 50,000
users at the same time. Users can access mainframes by
cither using terminals or via PCs. The two types of terminals
that can be used with mainframe systems are as follows:
Dumb Terminals
Dumb terminals consist of only a monitor and a keyboard
(or mouse). They do not have their own CPU and memory
Figure 1.7 ULSI chip and use the mainframe system's CPU and storage devices.
Intelligent Terminals
CLASSIFICATION OF COMPUTERS
In contrast to dumb terminals, intelligent terminals have
Computers can be broadly classified into four categories their own processor and thus can perform some processing
based on their speed, amount of data that they can process, operations. However, just like the dumb terminals, they do
and price (refer to Figure 1.8). These categories are as not have their own storage space. Usually, PCs are used
follows: as intelligent terminals to facilitate data access and other
+ Supercomputers services from the mainframe system.
+ Mainframe computers Mainframe computers are typically used as servers on
+ Minicomputers the World Wide Web. They are also used in organizations
* Microcomputers such as banks, airline companies, and universities. where
a large number of users frequently access the data stored
1.5.1 Supercomputers in their databases, IBM is the major manufacturer of
mainframe computers. Some examples of mainframe
Among the four categories, the supercomputer is the computers include IBM $/390, Control Data CYBER 176,
fastest, most powerful, and most expensive computer. and Amdah! 580.
Supercomputers were first developed in the 1980s to
process large amounts of data and to solve complex 1.5.3 Minicomputers
scientific problems, Supercomputers use parallel
processing technology and can perform more than one As the name suggests, minicomputers are smaller,
trillion calculations in a second. cheaper, and slower than mainframes. They are called
A single supercomputer can support thousands of users at minicomputers because they were the smallest computer
the same time, Such computers are mainly used for weather of their times. Also known as midrange computers, the
forecasting, nuclear energy research, aircraft design, capabilities of minicomputers fall between mainframe and
automotive design, online banking, controlling industrial personal computers.
Classification
of computers
are widely used in business, education, easily be carried from one place to another. They may also
hospitals, government organizations, ctc. While some be placed on the user's lap (thus the name). Hence, laptops
minicomputers can be used only by a single user, others are very useful, especially when going on long journeys.
are specifically designed to handle multiple users Laptops operate on a battery and do not always have to be
simultancously, Usually, single-user minicomputers are plugged in like desktop computers.
used for performing complex design tasks. ‘The memory and storage capacity of a laptop is almost
As with mainframes, minicomputers can also be used equivalent to that of a desktop computer. As with desktop
as servers in a networked environment, and hundreds of computers, laptops also have hard disk drives, USB drives,
PCs can be connected to it, etc, For input, laptops have a built-in keyboard and a
The first minicomputer was introduced by Digital trackball/touchpad, which is used as a pointing device (as
Equipment Corporation (DEC) in the mid-1960s, Other a mouse is used for a desktop PC).
manufacturers of minicomputers include IBM Corporation Today, laptops have the same features and processing
(AS/400 computers), Data General Corporation, and speed as the most powerful PCs. However, a drawback is
Prime Computer. that laptops are generally more expensive than desktop
computers. These computers are very popular among
1.5.4 Microcomputers business travellers.
The Intemet is a network of networks that stocks, finding a job, conducting an auction, marketing
connects computers all over the world. It gives the user and advertising products or services, and providing
access (0 an enormous amount of information, much more customer service. The following are techniques in which
than available in any library. Using e-mail, the user can e-commerce helps users to conduct business transactions.
communicate in seconds with a person who is located Business-to-consumer or B2C In this form of electronic
thousands of miles away. Chat software enables users commerce, business companies deploy their websites
to chat with another person in real-time (irrespective of on the Internet to sell their products and services to the
the physical location of that person), Video conferencing customers. On their websites, they provide features such
tools are becoming popular for conducting mectings with as cutalogues, interactive order processing system, secure
people who are unable to be present at a particular place. electronic payment system, and online customer support.
Digital video or audio composition Computers make
Business-to-business or B2B This type of electronic
audio or video composition and editing very simple. This
commerce involves business transactions performed
has drastically reduced the cost of equipment to compose between business partners (customers are not involved).
music or make a film. Graphics engineers use computers For example, companies use computers and networks (in
for developing short or full-length films and creating 3-D
the form of extranets) to order raw materials from their
models and special effects in science fiction and action
suppliers. Companies can also use extranets to supply
movies,
their products to their dealers.
Desktop publishing Desktop publishing software enables
Consumer-to-consumer or C2C This type of electronic
us to create page layouts for entire books.
commerce enables customers to carry business transactions
After discussing how computers are used in today’s among themselves. For example, on auction websites,
scenario, let us now have a look at the different areas a customer sells his/her product which is purchased by
where computers are being widely utilized. another customer.
special programs that compare the sequence of molecules Doctors sitting in hospitals can monitor their t
in DNA of a healthy person with that ofthe patient's. These sitting in their homes by using computer-based systems.
analyses help them to identify what is missing in a patient As soon as warning signs of serious illnesses are spotted,
and to determine drugs that can make the molecules in they alert the concerned doctor quickly.
DNA of the patient look similar to that of a healthy person.
For example, one of the drugs to treat AIDS was designed Geographic Information System and
using bioinformatics techniques.
Remote Sensing
Health care A geographic information system (GIS) is a computer-
based tool for mapping and analysing earth’s features.
Last few years have seen a massive growth of computers
It integrates database operations and statistical
and smartphone users. Like in our daily lives, computers
analysis to be used with maps. GIS manages location-
have also become 4 necessary device in the health care
based information and provides tools for display and
industry, The following are areas in which computers are
analysis of statistics such as population count, types of
extensively used in the health care industry.
vegetation, and economic development opportunities.
Storing records To begin with, computers are first and Such type of information helps to predict outcomes and
foremost used to store the medical records of patients. plan strategies.
Earlier, patient records were kept on paper, with separate Remote sensing is the science of taking measurements
records dealing with different medical issues from separate of the earth using sensors. on airplanes or satellites. These
healthcare organizations. With time, the number of sensors collect data in the form of images, which are then
prescriptions, medical reports, etc., grow in volume making analysed to derive useful information.
it difficult to maintain and analyse. Use of computers to The key feature of remote sensing is that it acquires
store patient records has been a game-changer in terms of information about an object without making physical
improving the efficiency and accuracy of the entire process. contact with it, Remote sensing is a sub-field of geography,
Now, the entire medical history of patients is easily which can be applied in the following areas to collect data
accessible, Since the records are electronically stored, they of dangerous or inaccessible areas for the following:
can be easily shared between different doctors (in same
* Monitoring deforestation in areas like the Amazon
or different healthcare organizations) who are treating
Basin
the same patient. Besides saving paper and enhancing * Studying features of glaciers in Arctic and Antarctic
efficiency, use of computers also saves patients’ money by regions
reducing duplication of tests and procedures.
Analysing the depth of coastal and ocean areas
Surgical procedures Computers are used for certain Studying land usage in agriculture
surgical procedures. They enable the surgeon to use Examining the health of indigenous plants and crops
computer to control and move surgical instruments in Determining the prospect for minerals
the patient's body for a variety of surgical procedures. In CUS
ewLocating and measuring intensity of earthquakes (after
such surgeries, a small incision is made, and then a small they had occurred) by comparing the relative intensity
surgical tool with an attached camera is placed inside the and precise timings of seismograms collected from
patient's body. This reduces the riskofcomplications from different locations
a larger surgical wound, and minimizes damage done to
the patient's body. In such a scenario, computers are not Meteorology
only used to drive the tools but also used to relay images
from inside the patient's body out to the doctors. Metcorology is the study of the atmosphere, This branch of
Computers also help to determine the cause of an science observes variables of Earth’s atmosphere such as
affliction or illness. For example, computers can combine temperature, air pressure, water vapour, and the gradients
ultrasonography and imaging in fields like cardiology to and interactions of each variable, and how they change
check the functionality of the heart. In case of a serious over time, Meteorology has applications in many diverse
ailment, the causes can be detected in less time and fields such as the military, energy production, transport,
treatment can be started at the earliest thereby saving a agriculture, and construction. Some of the applications
numberof lives. include the following:
Today, tablets and computers are being used in surgical Weather forecasting It includes application of science
consultations and videoconferencing between doctors. and technology to predict the state of the atmosphere
Better diagnosis and treatment Computers help (temperature, precipitation, etc.) for a future time and a
physicians make better diagnoses and recommend given location, Weather forecasting is done by collecting
treatments. Moreover, computers can be used to compare quantitative data about the current state of the atmosphere
expected results with actual results in order to help and analysing the atmospheric processes to project how
physicians make better decisions. the atmosphere will evolve.
{4 Computer Fundamentals and Programming in C
forecasts are especially made to generate explanation. However, they find it interesting to learn
warnings regarding heavy rainfall, snowfall, etc. They are through interacting with an animation of the algorithm
also important to agriculturists and also to commodity
traders within stock markets, Temperature forecasts
are used by utility companies to estimate demand over
coming days. Edutainment
isthecombination ofeducation with
entertainment.
Aviation meteorology Aviation meteorology studies the
impact of weather on air traffic management. It helps Legal System
cabin crews to understand the implications of weather on
their flight plan as well as their aircraft, Computers are used by lawyers to shorten the time required
to conduct legal precedent and case research. Lawyers use
Agricultural meteorology Agricultural meteorology computers to look through millions of individual cases and
deals with the study of effects of weather and climate on tind whether similar or parallel cases have been approved,
plant distribution, crop yield, water-use efficiency, plant denied, criticized, or overruled in the past. This enables
and animal development. the lawyers to formulate strategies based on past case
Nuclear meteorology Nuclear meteorology studies decisions. Moreover. computers are also used to keep
the distribution of radioactive aerosols and gases in the track of appointments and prepare legal documents and
atmosphere. briefs in time for filling cases,
Astronauts are trained using computer-simulated problems humans cannot work, For example, in high t
that could be encountered during launch, in space, or upon high pressure conditions or in processes that demand very
return to earth. high levels of accuracy. The main distinguishing feature
between a robot and other automated machines is that @
Astronomy robot can be programmed to carry out a complex task and
then reprogrammed to carry out another complex tasks.
Spacecrafts are usually monitored using computers that
not only keep a continuous record of the voyage and Decision Support Systems
of the speed, direction, fuel, and temperature, but also
suggest corrective action if the vehicle makes a mistake. Computers help managers to analyse their organization's
The remote stations on the carth compare all these data to understand the present scenario of their business,
quantities with the desired values, and in case these values view the trends in the market, and predict the future of their
need to be modified to enhance the performance of the products. Managers also use decision support systems to
spacecraft, signals are immediately sent that set in motion analyse market research data, to size up the competition,
the mechanics to rectify the situation. With the help of and to plan effective strategies for penetrating their
computers, all this is done within a fraction of a second. markets.
A computer is a powerful teaching aid and can act as Expert systems are used to automate the decision-making
another teacher in theclassroom, Teachers use computers to process in a specific area, such as analysing the credit
develop instructional material. Teachers may use pictures, histories for loan approval and diagnosing a patient's
graphs, and graphical presentations to casily illustrate condition for prescribing an appropriate treatment. Expert
an otherwise difficult concept. Moreover, teachers at all systems analyse the available data in depth to recommend
levels can use computers to administer assignments and a course of action. A medical expert system might provide
keep track of grades. Students can also give exams online
the most likely diagnosis of patient's condition.
and get instant results. To create an expert system, an extensive amount of
human expertise in a specific area is collected and stored
in a database, also known as a knowledge base. A software
Industry and Engineering
called an interface engine analyses the data available
Computers are found in all kinds of industries, such in the knowledge base and selects the most appropriate
as thermal power plants, oil refineries, and chemical response.
industries, for process control, computer-aided designing Adding more to it, in today’s scenario, computers are
(CAD), and computer-aided manufacturing (CAM). used to find jobs on the Internet, read news and articles
Computerized process control (with or without human online, find your batchmates, send and receive greetings
intervention) is used to enhance efficiency in applications pertaining to different occasions, etc.
such as production of various chemical products, oil
refining, paper manufacture, and rolling and cutting steel
to customer requirements. BASIC ORGANIZATION OF
In CAD, computers and graphics-oriented software are
integrated for automating the design and drafting process.
A COMPUTER
It helps an engincer to design a 3D machine part, analyse
A computer is an electronic device that performs five
its characteristics, and then subject it to simulated stresses. major operations:
In case a part fails the stress test, its specifications can be
modified on the computer and retested. The final design * Accepting data or instructions (input)
specifications are released for production only when the * Storing data
engineer is satisfied that the part meets strength and other * Processing data
quality considerations. * Displaying results (output)
The CAM phase begins when the CAD phase is * Controlling and coordinating all operations inside a
complete. In this phase, the metal or other materials are computer
manufactured while complying with their specifications. In this section, we will discuss all these functions and
For this computer controlled manufacturing, tools are used see how one unit of a computer interacts with another to
to produce high quality products. perform these operations. Refer to Figure 1.11, which
shows the interaction between the different units of a
Robotics computer system.
Robots are computer-controlled machines mainly used in Input This is the process of entering data and instructions
the manufacturing process in extreme conditions where (also known as programs) into the computer system, The
{(16 } Computer Fundamentals and Programming in C
Data and
é; R Input Storage Output Results
cru
Control unit
'
aga Flow of data and instructions
— Control exercised by control unit
data and instructions can be entered by using different only in binary form and the result of processing is also in
input devices such as keyboard, mouse, scanner, and binary form, the result cannot be directly given to the user.
trackball. Note that computers understand binary language, The output devices, therefore, convert the results available
which consists of only two symbols (0 and 1), so it is the in binary codes into a human-readable language before
responsibility of the input devices to convert the input data displaying it to the user.
into binary codes. Control The control unit (CU) is the central nervous
Storage Storage is the process of saving data and system of the entire computer system. It manages and
instructions permanently in the computer so that they can controls all the components of the computer system. It
be used for processing, The computer storage space not is the CU that decides the manner in which instructions
only stores the data and programs that operate on that data will be executed and operations performed. It takes care
but also stores the intermediate results and the final results of the step-by-step processing of all operations that are
of processing, performed in the computer.
A computer has two types of storage areas: Note that the CPU is a combination of the arithmetic
logic unit (ALU) and the CU. The CPU is better known
Primary storage Primary storage, also known as the main as the brain of the computer system because the entire
memory, is the storage area that is directly accessible by processing of data is done in the ALU, and the CU activates
the CPU at very high speeds. It isused to store the data and and monitors the operations of other units (such as input,
purts of programs, the intermediate results of processing, output, and storage) of the computer system.
and the recently generated results of jobs that are currently
being worked on by the computer. Primary storage space Processing The process of performing operations on the
is very expensive and therefore limited in capacity. data as per the instructions specified by the user (program)
Another drawback of main memory is that it is volatile is called processing. Data and instructions are taken from
in nature; that is, as soon as the computer is switched off, the primary memory and transferred to the ALU, which
the information stored gets erased. Hence, it cannot be performs all sorts of calculations. The intermediate results
used as a permanent storage of useful data and programs of processing may be stored in the main memory, as they
for future use. An example of primary storage is random might be required again. When the processing completes,
access memory (RAM). the final result is then transferred to the main memory.
Hence, the data may move from main memory to the ALU
Secondary storage Also known as auxiliary memory, multiple times before the processing is over.
this memory is just the opposite of primary memory, It
overcomes all the drawbacks of the primary storage area.
It is cheaper, non-volatile, and used to permanently store
data and programs of those jobs thal are not being currently
executed by the CPU. Secondary memory supplements
the limited storage capacity of the primary memory. An
example is the magnetic disk used to store data, such as C
and D drives, for future use. LAB SESSION—INSIDE THE
Output Output is the process of giving the result of data COMPUTER
processing to the outside world (external to the computer
system). The results are given through output devices such As a part ofthis chapter, the instructor must show the parts
as monitor, and printer. Since the computer accepts data of the computer to the students, as illustrated inFigure 1.12.
PS/2 Keyboard USK Serial! Serial? Graphics Secondary ethernet Sound card
The following are some of the major parts of the These days, many computers come with a built-in sound
computer: chip, which makes it unnecessary to buy a separate card
unless a higher quality of sound is needed,
CPU The CPU is the brain of the computer. It performs
all calculations and controls the devices connected to Modem A modem (modulator-demodulator) is a device
the computer system. The faster the CPU, the quicker that enables the computer to use a telephone line to
programs can process the instructions. communicate and connect to the Internet,
RAM A fast CPU is of no use if the computer does not Network card A network card is used to connect the
have sufficient RAM. As discussed earlier, RAM is the computer cither to other computers or to the Internet (in
computer's memory which stores information used by case you are using a fast Internet connection such as cable
applications that are currently being executed by the or DSL).
CPU. More memory means more applications can be
Fans There are one or more fans inside the computer to
executed at the same time without degrading the system's
performance. keep the air moving and the computer cool.
Hard disk drive (HDD) The HDD of the computer is Cables There are multiple wires inside the computer
the secondary memory of the computer system where that are flat, ribbon-like cables. They are used to provide
information is stored permanently. All types of data, power and communication to the various parts inside the
computer.
documents, and programs are stored on the hard disk.
The larger the hard disk, the more the amount of data that
can be stored on the drive. Though the size of the HDD
does not affect the speed of execution of the program, it MOTHERBOARD
does affect the speed at which the user can access his/
her files. The motherboard, also known as the mainboard or the
parent board (refer Figure 1.13), is the primary component
Video card The video card is a board that plugs into
of a computer. It is used to connect all the components
the motherboard of the computer and generates images
of the computer. The motherboard is a printed circuit that
for display. Many video cards these days have their own
has connectors for expansion cards, memory modules, the
RAM and processor to enhance the speed of the graphics
processor, etc.
display, Many computers come with an in-built video chip.
In such a computer, a separate video card is used only if
the computer has to be used for high-end multimedia work 1.9.1 Characteristics of a Motherboard
or to play video games, A motherboard can be classified depending on the
Soundcard As with video cards, sound cards are expansion following characteristics:
boards that are used to enable a computer to manipulate * Form factor
sound. For example, sound cards allow the users to plug in * Chipset
speakers and a microphone. Some sound cards also provide * Type of processor socket used
the jacks for hooking your computer up to a common stereo. * Input-Output connectors
18 Computer Fundamentals and Programming in C
Input-Output connectors
Jumpers Disk drive and floppy drive connectors Case fan power supply
connector
Form factor Form factor refers to the motherboard's of the computer (such as the processor and memory). In
geometry, dimensions, arrangement, and clectrical order to enhance the computer's upgradeability, one must
requirements. The industry has defined a few standards choose a motherboard that has the latest chipset integrated
for the form factors, so that they can be used in different in it, Some chipsets may include a graphics or audio chip,
brands of cases, which makes it unnecessary to install a separate graphics
card or sound card. However, in case you need very high
Integrated components Some of the motherboard’s
components are integrated into its printed circuitry. These quality of audio and visual capabilities, then you must
include the following: disable the graphics/audio chip in the BIOS setup and
install high-quality expansion cards in the appropriate slots.
* The chipset is a circuit that controls the majority of the
computer's resources such as the bus interface with the CMOS clock and battery The real-time clock (or RTC)
processor, cache memory, RAM, and expansion cards. is 4 circuit that is used to synchronize the computer's
* CMOS clock and battery signals. When the computer is switched off, the power
+ BIOS supply stops providing electricity to the motherboard.
* System bus and expansion bus You must have observed that when we turn on the system,
it always displays the correct time. This is because an
In addition to these, the latest motherboards also have
electronic circuit, called the complementary metal-
a number of onboard multimedia and networking devices oxide semiconductor (CMOS) chip, saves some system
(which can be disabled), such as integrated network
information, such as the time, date, and other essential
card, integrated graphics card, integrated sound card, and system settings,
upgraded hard drive controllers.
The CMOS chip is powered by a battery located on the
Chipset The chipset is an electronic circuit that basically motherboard. Information on the hardware installed in the
coordinates data transfers between the different components computer (such as the number of tracks or sectors on cach
Introduction to Computers
USB VGA
hard drive) is stored in the CMOS chip. Since the CMOS it and to improve the heat transfer. The fan vents hot air
chip is quite slow, some systems prefer to copy the CMOS from the case and lets fresh air come in from outside.
chip's content into the RAM, which is a comparatively RAM connectors RAM is the primary storage area that
faster storage. This process of copying data into RAM is stores data while the computer is running. However, its
better known as memory shadow. contents are erased when the computer is turned off or
Have you noticed that, at times, the system time gets restarted, While the hard disk can store data permanently,
reset automatically, or the clock runs late’? This indicates we still need RAM because it is extremely fast when
that you need to change the battery. compared to mass storage devices such as hard drives.
BIOS The basic inpuV/output system (BIOS) is an interface Therefore, the fast processor accesses data from RAM
between the operating system and the motherboard. and not from the hard disk. The data is transferred from
The BIOS is stored in the read-only memory (ROM), the hard disk to the RAM, from where it is used by the
which cannot be rewritten. The BIOS uses data stored processor. RAM is available in the form of modules that
in the CMOS chip to know about the system's hardware plug into motherboard connectors.
configuration, Expansion slots Expansion slots are compartments into
‘To configure the BIOS, the user can use an interface which expansion cards can be inserted. Such curds render
known as B/OS setup. which can be accessed when the new features or enhance the computer's performance. For
computer is booting. To enter BIOS setup, the user must example, the AGP slot (also known as Accelerated Graphic
press the DEL key. Fl and F2 keys can also be used. Port) is a fast port used for graphics cards,
Processor socket The processor (also called the micro- 1/0 connectors The motherboard has a number of input~
processor) is the brain of the computer, The processor is output sockets (Figure 1.14) on its rear panel, some of
characterized by its speed or frequency, which is the rate at which include:
which it executes instructions. For example, an 800-MHz
* A serial port to connect some old peripherals
processor can perform 800 million operations per second.
A parallel port to connect old printers
The slot on the motherboard into which the processor is
USB ports to connect more recent peripherals such as
inserted is called the processor socket or slot. Irrespective mouse and pen drive.
of whether you use a slot or a socket, you must gently
RJ45 connector (also known as LAN or Ethernet port)
insert the processor, so that none of its pins are bent (it has
to connect the computer to a network. It corresponds to
hundreds of them). Usually, a concept called zero insertion
a network card integrated into the motherboard.
force (ZIP) is used. The ZIF sockets allow the processor to
Video graphics array (VGA) connector fo connect &
be inserted very gently and casily.
monitor. This connector interfaces with the built-in
When the computer is on, the processor is working
graphics card.
and it releases heat, which must be dissipated to keep the
Audio plugs that include the line in, line out, and
circuits from melting. Therefore, the processor is generally
microphone to connect sound speakers, hi-fi system, or
mounted on a cooler that is made of metal (such as copper microphone, This connector interfaces with the built-in
or aluminum), which conducts heat well. In addition to the
sound card.
cooler, there is also a fan to improve air circulation around
POINTS TO REMEMBER
* Modern are based y
computers-da of
on the principle
. A computer is anelectronic machine that accepts data
the stored program concept, which was introduced by
and instructions and performs computations on the
data based on those instructions. Sir John von Neumann in the late 1940s.
. Computers are used in allinteractive devices, such as * The speed of the computer is usually given in
nanoseco and picoseco
nds nds.
cellular telephones, GPS units, portable organizers,
ATM s,
and gas pumps.
G) Computer Fundamentals and Programming in C
© The term computer generation refers to the different of integrated circuits built
computers, with thousands
advancements of new computer technology. With on to a single silicon chip.
each new generation of computers, the circuitry has © Fifth-generation computers are manufactured using
become smaller and more advanced than that in its integrated chips (ICs) built with ultra-large scale
previous generation, integration (ULSI) technology.
© First-generation computers used a very large number © The CPU is a combination of the ALU and the CU. The
of vacuum tubes for circuitry and magnetic drums for CPU is known as the brain of the computer system.
memory. * The CU is the central nervous system of the entire
* Second-generation computers were manufactured computer system. It manages and controls all the
using transistors rather than vacuum tubes. components of the computer system.
* The development of the integrated circuit was the * The motherboard, also known as the mainboard or
hallmark of the third generation ofcomputers. the parent board, is the primary component of a
¢ The microprocessor started the fourth generation of computer.
| GLOSSARY
Tee "Kcomputer is an electronic machine thattakes computers all over the world.
instructions and performs computations based on those Memory shadow The process ofcopying data from CMOS
instructions. into RAM.
Expert systems Expert systems arecustom-written computer Program Aset of instructions executed by the computer.
programs that are ‘expert’ ina particular problem area, and Robotics Computers programmed to look, listen, and
embody a human expert’s knowledge, experience, and react to other sensory stimuli.
problem-solving strategies. They are being used in many Semiconductor devices Semiconductor devices are
areas such as medicine, chemistry, geology, meteorology, and electronic components that make use of the electronic
computer systems. properties of semiconductor materials (such as silicon
Garbage-in, garbage-out |f input data is wrong, then the and germanium). The conductivity of such devices can be
output will also be erroneous. controlled by introducing an electric field, by exposure to
making such
GUI A GUI is a type of user interface that enables users to light, and even pressure and heat, thereby
Interact with programs in more ways than typing. A GUI! devices excellent sensors.
offers graphical icons and visual indicators to display the Storage The process of saving data and instructions
Information and actions available toa user. The actions are permanently in the computer so that it can be used for
performed by direct manipulation ofthe graphical elements. processing.
Input The process of entering data and instructions into Stylus Astylus isan electronic pen that looks like a small
the computer system. ballpoint pen.
Integrated circuit Also called a chip or microchip, an IC Transistor A transistor is a semiconductor device that is
is a semiconductor wafer on which thousa millions used to amplify and switch electronic signals. Although
ornds
of tiny resistors, capacitors, and transistors are fabricated. some transistors are packaged individually, others are
it can be used as an amplifier, oscillator, timer, counter, usually found embedded in ICs.
computer memory, or microprocessor. Vacuum tube A vacuum tube is a device used to amplify
InternetIt is a network of networks that connects electronic signals.
EXERCISES
Fill in the Blanks 4. The speed of computers is expressed in or
1, Aprogram is the
based on 5. Raw facts or figures are called
2. Computers operate on
calculations in a second.
6. is an example of primary memory.
3. Computers can perform
and______ are examples offirst-generation 6. The brain of the computer is the
computing devices. (a) control unit (b) ALU
. Second-generation computers were first developed for {e) CPU (d) All of these
the industry.
3 packages allow easy manipulation and analysis State True or False
of data organized in rows and columns.
1. Computers work on the GIGO concept.
|. CRAY-1, CRAY-2, Control Data CYBER 205, and ETA A-10
are -
2. Lnanosecond = 1x10"™ seconds,
3. Floppy disks and hard disks are examples of primary
enables the computer to use a telephone line memory.
to communicate
and connect to the Internet.
4. First-generation computers used a very large number of
connector is used to connect a monitor. transistors.
hs concept was introduced by Sir John von
5. First-generation computers could be programmed only
Neumann
in the late 1940s.
in binary language.
. Android Jellybean, Windows, and iOS are all examples of
ALGOL is used in the third generation of computers,
popular operating systems used in and
. Fifth-generation computers are based on Al.
f is an interface between the operating system Network computers have more processing power,
memory, and storage than a desktop computer.
and the motherboard.
. RAM stores the data and parts of program, the
Multiple-choice Questions intermediate results of processing, and the recently
generated resultsofjobs that are currently being worked
1, Which was the first commercial computer delivered to a
on by the computer.
business client?
10. Aserial port is used to connect old printers,
(a) UNIVAC (b) ENIAC
{c) EDSAC (d) Noneof these Review Questions
. Which technology was used to manufacture second- 1. Define a computer.
generation computers? 2. Differentiate between data and Information,
(a) Vacuum tubes (b) Transistors 3. Differentiate between primary memory and secondary
(c) ICs {d) None of these memory.
. Time sharing operating systems were used in which 4. Write a short note on the characteristics of a computer.
generationof computers? 5. Computers work on the garbage-in, garbage-out
(a) First {b) Second concept. Comment.
(c) Third (d) Fourth 6. Explain the evolution of computers. Further, state how
. Choose the computer languages that are specially computers in one generation are better than their
designed for the fifth generationofcomputers. predecessors.
. Broadly classify computers based on their speed, the
(a) ALGOL ({b) SNOBOL amount ofdata that they can hold, and price.
(c) Lise {d) Prolog Discuss the variants of microcomputers that are widely
. Web TV is an exampleof used today,
(a) supercomputer {b) minicomputer . Explain the areas in which computers are being applied
(c) network Computer (d) laptop to carry out routine and highly-specialized tasks,
put and Output Devices
and the
an inverted T-type fashion between the typing
r on the
INPUT DEVICES numeric keys, and are used to move the curso
addit ion to the arrow keys,
screen in small increments. In
keys) , such as:
An input device is used to feed data and instr
uctions into there are other cursor keys (or navigational
uter
‘a computer, In the absence of an input device, a comp + Home and End to move the cursor to the begin
ning and
on,
would have only been a display device, In this secti end of the current line, respectively
es,
we will read about some of the widely used input devic * Page Up and Page Down to move the curso
r up and
into diffe rent group s. ly.
Figure 2.1 categorizes input devices down by one screen at a time, respective
existing
+ Insert to enter a character between two
2.1.1 Keyboard characters
ion
ters. + Delete to delete a character at the cursor posit
The keyboard is the main input device for compu
Computer keyboards look very similar to the keybo ards Other common control keys on the keyboard include
Print Screen,
of typewriters, with some additional keys, as show n in Control (Ctrl), Alternate (Alt), Exeape (Esc),
Windows
Figure 2.2. Pause, the Windows or Start key (Microsoft
s
Using a keyboard, the user can type & document, use logo), and a shortcut key. The shortcut key is used to acces
right mous e butto n.
keystroke shortcuts, access menus, play games
, and the options available by pressing the
perform numerous other tasks. Most keybo ards have The Esc key cancels the selected option, and the Pause
between 80 and 110 keys, which include the following: key suspends a command/process in progress. Finally, the
n as an
bet. Print Screen key captures everything on the scree
Typing keys These include the letters of the alpha image. The image can be pasted into any docu ment .
RTY for
The layout of the keyboard is known as QWE
its first six letters. The QWERTY pattern has been a
were
standard right from the time computer keyboards
introduced.
Numeric keys These include a set of keys, arranged in the
data
same configuration found on calculators to speed up
entry of numbers. When the Num Lock key is set to ON,
~,
the user can type numbers, dot, or input the symbols /, *,
and +. When the Num Lock key is set to OFF, the numer ic
Inside the Keyboard
keys can be used to move the cursor on the screen,
Function keys These are used by applications and A keyboard is like a miniature computer that has its own
operating systems to input specific commands, They processor and circuitry to carry information to and from
are often placed on the top of the keyboard in a single that processor. The circuitry has a key matrix, which is
row. Function keys can be programmed so that their a grid of circuits underneath the keys. Each circuit is
functionality varies from one program to another, broken at a point below each key. When a key is pressed,
it corresponds to pressing a switch, thereby completing
Control keys These are used to handle control of the
the circuit,
cursor and the screen. Four arrow keys are arranged in
Input and Output Devices Gs
Input devices
OMR
MICR
Mouse
The mouse is an input device that was invented by Douglas
Engelbart in 1963. It is the key input device used in a
graphical user interface (GUI). It can be used to handle the
Figure 2.2 Keyboard pointer easily on the screen to perform various functions
such as opening a program or file. With the mouse, the users
Source: digital art/FreeDigitalPhotos.net
no longer need to memorize commands, which was earlier
a necessity when working with text-based command line
environments like MS-DOS. A mouse is shown in Figure 2.3,
Barcode Reader
A barcode reader (also price scanner or POS scanner) is
a handheld input device that is used to capture and read
information stored in a barcode. It consists of a scanner,
a decoder, and a cable used to connect the reader to a
computer, The function of the barcode reader is to capture
and translate the barcode into numerals and/or letters. It
is connected to a computer for further processing of the
captured information, This connection is achieved through
a serial port, keyboard port, or an interface device called
awedge. Figure 2.10 Flatbed image scanner
Abarcode reader works by directing a beamof light across Source: Mile Atanasov/Shutterstock
the barcode and measuring the amount of light reflected
back. The dark bars reflect less light when compared to the Some scanners can be connected to the computer using
amount of light reflected by the white spaces between those a small computer system interface (SCSI). Some major
bars. The scanner converts this light energy into electrical manufacturers of scanners are Epson, Hewlett-Packard,
energy, The decoder then converts these signals into data Microtek, and Relisys, The basic types of image scanners
and sends it to the computer for processing. are flatbed, hand, film, and drum scanners.
These days, barcode readers are widely used in The scanners that we see in our colleges or offices are
following areas: flatbed scanners. In this type, the object to be scanned is
placed on a glass pane and an opaque cover is lowered over
* Generate bills in supermarkets and retail stores
it. A sensor and light move along the pane, reflecting off
* Take stock of inventory in retail stores
the image placed on the glass. The cover is used to prevent
* Check out books from a library other light from interfering, and the image becomes visible
* Track manufacturing and shipping movement
to the detector.
* Keep track of employee login
A hand image scanner has to be manually moved across
* Identify hospital patients the object or image to be scanned. The scanner produces
* Tabulate the results of direct mail marketing returns
light from green light emitting diodes (LEDs), which
* Tag honeybees used in research
highlight and scan the image onto a computer for further
Advantages processing. However, these days, 3D image scanners have
* Barcode readers are inexpensive. become the most popular form of hand scanners, as they
* They are portable. are able to compensate for jerky hand movements during
* They are handy and easy to use. scanning.
Input and Output Devices @
Film scanners are usually used in photography and In OCR processing, the analysis of the scanned i
slides. The slide or negative film is first inserted in strips is done to detect light and dark areas so as to identify each
of six or less frames into the film scanner, and then moved letter or numeral. When a character is recognized, it is
across a lens and sensor to capture the image. converted into an ASCII code.
While handheld and film scanners use charge coupled OCR has facilitated users to store text documents as
device (CCD) arrays, drum scanners. on the other hand, text files (rather than as images, as in case of scanners).
use photo multiplier tubes. Drum scanners are mounted Hence, the text files occupy much less storage space and
on an acrylic cylinder that rotates while passing the object can be easily edited. These days, OCR is widely used in
in front of precision optics, which in tum transfers the the following areas:
image information to the photo multiplier tubes, Most * Digitize and preserve documents in libraries
drum scanners use three matched PMTs that are capable * Process checks and credit card slips
of detecting red, blue, and green light. The light of the + Sort letters for speeding up mail delivery
object being scanned is separated into red, blue, and green Letus takeareal-world example to understand the power
beams. Drum scanners are very expensive and are often
of OCR. The police department usually has all the criminal
used for high-end applications of film.
records stored in large file cabinets. Seanning millions of
Advantages pages to find a particular record is not only tedious and
* Any printed or handwritten document can be scanned error-prone but also an expensive process. However, if
and stored in a computer for further processing. OCR is used to convert the pages into computer-readable
* The scanned and stored document will never deteriorate text, the police can casily search through the entire
in quality with time. The document can be displayed history in a few seconds. OCR technology can be easily
and printed whenever required. understood from Figure 2.11.
* There is no fear of loss of documents. The user can scan Advantages
important documents and store them permanently in the + Printed documents can be converted into text files.
computer. + Advanced OCR can recognize handwritten text and
Disadvantages convert it into computer-readable text files.
* Scanners are usually costlier than other input devices. Disadvantages
* The documents that are scanned and stored as images + OCR cannot recognize all types of fonts.
have a higher size as compared to other equivalent text
+ Documents that are poorly typed or have strikeover
files. cannot be recognized.
* Text documents are scanned and stored as images. + Very old documents when passed through OCR may not
Therefore, they occupy more space and are also convert into anexact copy of the text file. This is because
uneditable because computers cannot interpret
some characters may not have been recognized properly.
individual characters and numbers in the image.
In such cases, the user has to manually edit the file.
Optical Character Recognition (OCR) Device Optical Mark Recognition (OMR) Device
Optical character recognition is the process of converting Optical mark recognition is the process of electronically
printed materials into text or word processing files that can extracting data from marked fields, such as checkboxes
be easily edited and stored. The steps involved in OCR and fill-in fields, on printed forms. The optical mark reader,
include: as shown in Figure 2.12, is fed with an OMR sheet that has
* Scanning the text character by character pen or pencil marks in pre-defined positions to indicate
+ Analysing the scanned image to translate the character each selected response (¢.g., answers for multiple-choice
images into character codes (¢.g., ASCII) questions in an entrance examination).
Printed
documents:
Magnetic
ink character recognition
Video input devices are used to capture video from the
outside world into the computer. Here, the term video
Figure 2.13 A cheque containing magnetic ink characters means moving picture along with sound (as in television).
printed on it As we have sound cards to convert analog audio signals
= W
Input and Output Devices (9 i
a Sound card
4 Speakers
The user speaks in The sound card converts analog ‘The sound card converts digital data stored
the microphone signals into digital data sothat itcan in the computer into analog signals and
be stored in thecomputer sends ittothe speakers sothat users may
hearthe sound
into digital data and vice versa, we also have video cards * They can be used to record memorable moments in
to convert analog video signals to digital data fo store it one’s life.
in the computer (and vice versa). Digital camera and web * They can also be used for security purposes,
camera are popular examples of video input devices.
Disadvantages
A digital camera as shown in Figure 2.15(a) is a * Audio input devices are not effective in noisy places,
handheld and easily portable device used to capture + With audio input devices, it is difficult to clearly
images or videos. The digital camera digitizes image or distinguish between two similar sounding words such
video (converts them into Is and 0s) and stores them on
as ‘sea’ and ‘see’.
a memory card. The data can then be transferred to the * Videos and images captured using video input devices
computer using a cable that connects the computer to the have very big file sizes, and they must be compressed
digital camera, Once the images or videos are transferred before being stored on the computer.
to the computer, they can be easily edited, printed, or
transmitted (c.g., through e-mails),
As with digital cameras, web cameras (also called OUTPUT DEVICES
webcams) too capture videos that can be transferred
via the Internet in real-time, Web cameras are widely Any device that outputs/gives information from a computer
used for videoconferencing. They are not very costly, can be called an output device. Basically, output devices
and this is one reason why they are so widely used for are electromechanical devices that accept digital data (in
security and privacy purposes. Webcams are also used the form of 0s and 1s) from the computer and convert them
4s security cameras, since PC-connected cameras can be into human-understandable language.
used to watch for movement and sound, recording both Since these days all computers are multimedia-enabled,
when they are detected, These recordings can then be the information from computers is usually output in cither
saved in the computer and used to detect or investigate visual or auditory format. Monitors and speakers are two
theft or any other crime. A web camera is shown in widely used output devices. These devices provide instant
Figure 2.15(b). feedback to the user's input. For example, monitors
display characters as they are typed. Similarly, speakers
Advantages play a song instantly when the user selects one from a
* Audio devices can be used by people who are visually playlist. Other examples of output devices include printers,
impaired. plotters, and projectors.
* Audio input devices are best used in situations where In this section, we will discuss these output devices.
users want to avoid input through keyboard or mouse. However, before going into their details, let us classify the
+ Video input devices are very useful for applications output devices based on whether they give a hard copy or
such as videoconferencing, a soft copy output (refer Figure 2.16).
Hard
copy devices
Projector Speaker
* Soft copy cannot be used by people who do not have a glass tube. The ray is a stream of electrons that come
computer. out from a heated cathode into the vacuum, While
* Scarching for data in a soft copy is easy and fast. electrons are negative, the anode, on the other hand, is
* Electronic distribution of material as soft copy is positive, so it attracts the electrons coming out of the
cheaper, It can be done easily and quickly. cathode. That is, the focusing anode focuses the stream
of electrons to form a tight beam that is then accelerated
Monitors by an accelerating anode. This tight, high-speed beam of
The monitor is a soft copy output device used to display electrons flies through the vacuum in the tube and hits
video and graphics information generated by the computer the flat screen at the other end of the tube, This screen is
through the video card. Computer monitors are similar to coated with phosphor, which glows when struck by the
television screens but they display information at a much beam, thereby displaying a picture, which the user sees
higher quality, The monitor is connected to cither the VGA on the monitor,
or the digital video interface (DVI) port on the video card
(on the motherboard or separately purchased).
Monitors come in three variants—cathode ray
tube (CRT), liquid crystal display (LCD), and plasma Note that, colour CRT monitors contain three electron
(refer Figure 2,17), While CRT monitors look much guns (one each for red, blue, and green).
like traditional televisions and are very huge in size, ach pixel ordot on the screen has three phosphors (red,
LCD monitors on the other hand are thinner, offering blue, and green). When the beam from these guns is
equivalent graphics quality. However, these days, LCD focused on the phosphors, they light up. Byvarying the
monitors are replacing CRT monitors as they are cheaper intensities ofthe beam, the user can obtain different
and occupy less space on the desk. Most monitors have colours.
a size range of 15’ to 21’ or more (where size is defined
as a diagonal measurement from one corner of the screen
to the other). Advantages
CRT monitor CRT monitors work by firing charged * CRT monitors provide images of good quality (bright as
well as clear).
electrons at a phosphorus film (refer Figure 2.18). When
electrons hit the phosphor-coated screen, they glow, * CRT monitors are cheapest when compared to LCD and
thereby enabling the user to see the output. plasma monitors.
In a CRT, the cathode (negative terminal) is a heated * The images are clear even when you try to view it from
filament that is placed in a vacuum created inside a an angle.
Input and Output Devices GI
9 |
to allow users to talk and listen at the same time, using
the same device. Headsets are widely used in call centers
and other telephone-intensive jobs, and for personal use
on the computer to facilitate comfortable simultancou
conversation and typing. Figure 2.22 shows the various
audio devices used with computers,
Although every computer has a built-in speaker, an
Figure 2.21 Projector external speaker disables this lower-fidelity built-in
Source: olegbush/Shutterstock speaker. Speakers available in the market have a wide
Input and Output Devices 33
HB 6
information. Colour printers can also be set to print only
in monochrome. These printers are more expensive, so if
the users do not have a specific need for colour and usually
take a lot of printouts, they will find a black-and-white
printer cheaper to operate.
2.2.2 Hard Copy Devices Memory Most printers have a small amount of memory
(for example, | MB), which can be expanded by the user.
Hard copy output devices are those that produce a physical
Having more memory enhances the speed of printing.
form of output. For example, the content of a file printed
Printers can be broadly classified into two groups:
on paper is a form of hard copy output. The features of
impact and non-impact printers as shown in Figure 2.23.
hard copy output include
* Acomputer is not needed to sce the output Impact Printer
Editing and incorporating the edits in the hard copy is These printers print characters by striking an inked ribbon
difficult against the paper. Examples of impact printers include dot
* Hard copy output can be easily distributed to people matrix printers, daisy wheel printers, and most types of
who do not have a computer line printers
* Searching for data in a hard copy is a tiring and difficult
job. Advantages
* Distribution of hard copy is not only costly but slower * These printers enable the user to produce carbon copies.
as well * They are cheap.
Disadvantages
Printers + Impact printers are slow
A printer is a device that takes the text and graphics * They offer poor print quality, especially in the case of
information obtained from a computer and prints it on graphics.
a paper, Printers are available in the market in various * They can be extremely noisy
sizes, speeds, sophistication, and costs, Usually, more * They can print only using the standard font
expensive printers are used for higher-resolution colour
printing. The qualities of printers that are of interest to Non-impact printer
users include
Non-impact printers are much quieter than impact printers,
Colour Colour printouts are needed for presentations, as their printing heads do not strike the paper. They offer
maps, and other pages where colour is part of the better print quality, faster printing, and the ability to create
Impact printers
Prints that contain sophisticated graphics. Non-impact The speed of dot matrix printers varies in the range of
printers use cither solid or liquid cartridge-based ink, 50-500 cps (characters per second).
which is cither sprayed, dripped,orclectrostatically drawn
Advantages
onto the page. The main types of non-impact printers are
* The dot matrix printer can produce carbon copies.
inkjet, laser, and thermal printers.
* It offers the lowest printing cost per page.
Advantages * It is widely used for bulk printing where the quality of
* Non-impact printers produce prints of good quality, and the print is not of much importance.
hence render sophisticated graphics. + Itis inexpensive
re noiseless. * When the ink is about to be exhausted, the printout
re fast gradually fades rather than suddenly stopping partway
* They can print text in different fonts. through a job.
Disadvantages * Itcan use continuous paper rather than individual sheets,
+ These printers are expensive making them useful for data logging.
* The ink cartridges used by them are also costly Disadvantages
In this section, we will read about the different types of + This type of printer creates a lot of noise when the pins
the printers. strike the ribbon against the paper.
* Itcan only print lower resolution graphics, with limited
Dot matrix printer A dot matrix printer (shown in
quality
Figure 2.24) prints characters and images of all types
* Itis very slow
as a pattern of dots (hence the name). This printer has a
printhead (or hammer) that consists of pins representing * It has poor print quality
the character or image. The printhead runs back and forth, Daisy wheel printer Daisy wheel printers use an impact
or in an up-and-down motion on the page and prints by printing technology to generate high quality output
striking an ink-soaked cloth ribbon against the paper, comparable to typewriters, and are three times ter
much like the print mechanism of a typewriter However, today, daisy wheel technology is found only in
some electronic typewriters,
The printhead of a daisy wheel printer is a circular
wheel, about 3 inches in diameter with arms or spokes.
The shape of the printer wheel resembles the petals of
a daisy flower, and hence its name. The characters are
embossed at the outer ends of the arms.
To print a character, the wheel is rotated in such a way
that the character to be printed is positioned just in front
of the printer ribbon. The spoke containing the required
character is then hit by a hammer, thereby striking the
ribbon to leave an impression on the paper placed behind
the ribbon. The movement of all these parts is controlled
Figure 2.24 Dot matrix printer
by a microprocessor in the printer.
The key benefit of using a daisy wheel printer is that
Source: burnel1/Shutterstock the print quality is high, as the exact shape of the character
hits the ribbon to leave an impression on the paper.
From the 1970s to 1990s, dot matrix impact printers
were the most common type of printers used with PCs. Line printer A line printer is a high-speed impact printer
Several dot matrix printer manufacturers implemented in which one typed line is printed at a time. The speed
colour printing through a multi-colour ribbon. Colour was of a line printer usually varies from 600 to 1200 lines
obtained through a multi-pass composite printing process per minute, or approximately 10-20 pages per minute.
In cach pass, the printhead struck a different section of the Because of their high speed, line printers are widely
ribbon (one primary colour), However, because of poor used in data centers and in industrial environments, Band
colour quality and increased operating expense, colour printer is a commonly used variant of line printers.
dot matrix printers could never replace their monochrome
counterparts, Moreover, the black ink section would Band printer A band printer (loop printer), is an impact
gradually contaminate the other three colours (RGB), printer with a printing mechanism that uses a metal loop
thereby changing the consistency of printouts over the life or band to produce typed characters, The set of characters
of the ribbon. The colour dot matrix printer was therefore are permanently embossed on the band, and this set cannot
suitable only for abstract illustrations and pie charts, but be changed unless the band is replaced. The band itself
not for photo-realistic reproduction revolves around hammers that push the paper against the
Input and Output Devices &
ribbon, allowing the desired character to be produced on inkjet printers have to be changed more frequently,
the paper. the special coated paper required to produce high quality
The main advantage of using a band printer is its output is very expensive. Hence, the cost per page of
high speed. This type of printer can print 2000 lines per inkjet printers becomes ten times more than laser printers.
minute, and is, therefore. perfect for high volume printing Therefore, inkjet printers are not well suited for high
in businesses, schools, and other organizations. Band volume print jobs.
printers are normally attached to mainframes and used for Laser printer A laser printer, shown in Figure 2.26,
industrial printing.
is a non-impact printer that works at very high speeds
However, band printers cannot be used for any graphics and produces high-quality text and graphics. It uses
printing, as the characters are predetermined and cannot the technology used in photocopier machines. When a
be changed unless the band is changed. Band printers were
document is sent to the printer, the following steps take
very popular in the 1970s and 1980s; however, today, laser place:
printers have replaced band printers.
+ A laser beam ‘draws’ the document on a drum (which
is coated with a photo-conductive material) using
electrical charges.
Band printers are often confused with band printing. * After the drum is charged, it is rolled in a toner (a dry
Band printing istheprocess ofsending output toa powder type of ink).
printer and isnot associated with this type ofprinters. * The toner sticks to the charged image on the drum,
* The toner is transferred onto a piece of paper and fused
Inkjet printer Inkjct printers, shown in Figure 2.25, came to the paper with heat and pressure.
in the market in the 1980s, but it was only in the 1990s that * After the document is printed, the electrical charge is
their prices reduced enough to bring the technology to the removed from the drum and the excess toner is collected.
high street. Inkjet printers have made rapid technological
advances in recent years. The colour inkjet printers have
succeeded in making colour printing an affordable option
even for home users.
POINTS TO REMEMBER
* An input device is used to feed data and instructions The sound card is a hardware unit that converts
into the computer. analog signals generated through the microphone
© Keyboard is an electro-mechanical device, which is into digital data, so that it can be stored in the
used to input alphanumeric data into the computer. computer.
A pointing input device enables the users to easily Video input devices are used to capture video from
control the movement of the pointer, It is connected the outside world into the computer.
to the serial or USB port on the system unit. * Any device that outputs/gives information from a
Mouse is an input device, which enable users to control computer can be called an output device, Basically,
the movement of the pointer in graphical user interface output devices are electromechanical devices that
A joystick is a cursor control device widely used in accept digital data from the computer and convert
computer games and CAD/CAM applications. them into human understandable language.
A stylus is a pen-shaped input device used to enter * The monitor is a soft copy output device used to
information or write on the touchscreen of a phone. display video and graphics information generated by
A touchscreen is a display screen that can identify the the computer through the video card. It is connected
occurrence and position of a touch inside the display to either the VGA or the DVI port on the video card
region. (which is on the motherboard or separately
A barcode reader is a handheld input device used to purchased).
capture and read information stored in a barcode. A projector is a device that takes an image from a
A scanner is a device that captures images, printed video source and projects it on a screen or another
text, and handwriting, from different sources such as surface,
photographic prints, posters, and magazines, and * Dot matrix printer is an impact printer, which prints
converts them into digital images for editing and characters and images as a pattern of dots.
display on computers. * Laser printer is a non-impact printer, which uses a
© Audio devices are used to either capture or create laser beam to produce an image on a negatively-
sound, Microphones and CD players are examples of charged cylindrical drum.
two widely used audio devices.
Input and Output Devices 37
GLOSSARY
impact printer A printer that works by striking an inked extracting data from marked fields, such as checkboxes
ribbon against the paper and fill-in fields, on printed forms
Input device A device that is used to feed data and Outputdevice Adevice
thatisused to present information
instructions into the computer from the computer to the user
Optical character recognition The process of converting Pointing device A device that enables the users to easily
printed materials into text or word processing files that control the movement of the pointer to select items on
can be easily edited and stored a display screen, to select commands from the command
Optical device A device that uses light as a source of input menu, to draw graphics, etc
for detecting or recognizing different objects Printer Adevice that takes the text and graphics information
Optical mark recognition The process of electronically obtained from a computer and prints it on paper
EXERCISES
Fill in the Blanks 3. Select the printer that uses impact printer technology
1, _____ is used to feed data and instructions into the from the following options
computer. (a) Daisy wheel (b) Laser
2 captures everything on the screen as an {c) Band (d) Inkjet
image. 4. Select the pointing devices from the following options:
3, The movement of an optical mouse is detected using
(a) Keyboard (b) Barcode reader
ae WAVES,
{c) Joystick (d) Touchscreen
4, ___ is used to enter information or write on the
5. Which type of screen is used in gaming devices, clocks,
touchscreen of a phone.
watches, calculators, and telephones?
5. A barcode reader is connected to the computer through
aL port. (a) LCD (b) Plasma
6 sttechnology is used for electronically extracting ({c) CRT (d) All of these
data from marked fields.
7. ____ converts analog signals generated through a State True or False
microphone into digital data 1, Home and End keys move the cursor to the previous and
8, ______s capture videos that can be transferred via the next page, respectively.
Internet in real-time 2. Pointing devices can be connected to the USB port of a
9. allow the users to talk and listen at the same computer.
time. 3, The movement of the cordless mouse is detected using
10, The resolution of a printer means laser technology.
4. OCR is used to verify the legitimacy or originality of
Multiple-choice Questions paper documents.
1, Which keys are used by applications and operating 5. The monitor is a soft copy output device.
systems to perform specific commands? 6. Non-impact printers create characters by striking an
(a) Typing keys (b) Arrow keys inked ribbon against the paper.
7. A laser printer uses the same technology used in
() Control keys (d) Function keys
photocopier machines.
2, Select the optical devices from the following options
8. A plotter is used to print vector graphics
(a) MICR (b) Barcode reader
9. A mouse cannot be used with a laptop computer.
(c) Scanner (d) All of these
38 ‘Computer Fundamentals and Programming in C
10, Soft copy output devices are those that produce a 11 Under which situation, will you prefer to use an inkjet
physical form of output. printer over a laser printer?
12 How is a plotter different from a printer?
Review Questions 13. Explain the variants of plotters.
1, How does a keyboard work? 14 What are input devices? Discuss the different types of
2. Explain the working of different types of mouse. input devices in detail.
3, How is OCR technology better than an ordinary image 15. Give a detailed note on different output devices.
scanner? 16. How is a touchpad better than a trackball?
4, How does MICR technology help to detect fraud in 17, Which pointing input device would you prefer to use,
cheque payments? mouse or trackball? Justify your answer.
5, Web cameras can be used to check security in a bank 18. List the applications of touchscreen
Comment 19. What are optical input devices? Where are they used
6. How are projectors used to display information to a and for what purpose?
user? 20, Differentiate between a soft copy and a hard copy
7. How are headsets better than speakers and headphones? output
8. Differentiate between impact and non-impact printers. 21 Which factors will you consider while purchasing a
9. Can characters of different fonts be printed with a band monitor for your personal computer? After considering
printer? the factors, which monitor will you buy?
10. Why is a line printer preferred over a dot matrix printer? 22 What is a data projector? How is it different from a
if you have an image to be printed, which out of the two computer screen?
will you use and why?
Computer Memory and
“Processors
TAKEAWAYS
* Sequential access © Magnetic tapes * Memory cards
* Random access © Floppy disks © Mass storage devices
* Processor registers © Hard disks * Processor architecture
* Cache memory © Optical drives * Pipelining
© Primary memory © USB flash drives * Parallel processing
* Secondary memory
in nature. In this section, we will read about the different while reading a bit, the transistor checks for a charge if
types of RAM and ROM available in the market the capacitor. Ifacharge is present, then the reading is 1;
if not, the reading is 0.
3.6.1 Random Access Memory (RAM) However, the problem with DRAM is that the capacitor
leaks energy very quickly and can hold the charge for
RAM is a volatile storage area within the computer that only a fraction of a second. Therefore, a refresh process
is typically used to store data temporarily, so that it can is required to maintain the charge in the capacitor so that
be promptly accessed by the processor. The information it can retain the information. This refreshing process is
stored in the RAM is basically loaded from the computer's carried out multiple times in a second and requires that all
hard disk, and includes data related to the operating cells be accessed, even if the information is not needed.
system and applications that are currently being executed However, the advantage of DRAM over SRAM is that
by the processor. it is cheap, can hold more data per chip, and generates less
RAM is considered random access because any memory heat than SRAM. DRAM is widely used to build the main
cell can be directly accessed if its address is known. When memory. The following are the different types of DRAM:
the RAM gets full, the computer system operates at a slow
Synchronous DRAM (SDRAM) SDRAM synchronizes
speed. When multiple applications are being cxecuted
itself with the clock speed of the microprocessor to enable
simultaneously and the RAM gets fully occupied by
faster access lo memory
the application's data, it is searched to identify memory
portions that have not been utilized. The contents of those Enhanced SDRAM (ESDRAM) This version of SDRAM,
locations are then copied onto the hard drive. This action though not widely used, includes a small SRAM cache to
frees up RAM space and enables the system to load other reduce delays in data access and speed up operations,
pieces of required data. Double data rate SDRAM (DDR) DDR allows data
These the applications’ and operating system's transfers on both the rising and falling edges of the clock
demand for system RAM has drastically increased. For cycle, which doubles the data throughput, DDR SDRAM
example, in the year 2000, a personal computer (PC) had chips are available in capacities of 128MB to 1GB
only 128 MB of RAM, but today PCs have 1-2 GB of RAM Although DDR memory is very common, the technology
installed, and may include graphics cards with their own is becoming outdated and is being replaced by DDR2,
additional $12 MB or more of RAM. As discussed carlicr,
there are two types of RAM—static RAM (SRAM) and DOR2 These chips are the next generationofDDR SDRAM
dynamic RAM (DRAM). memory. It can hold 256 MB to 2GB of memory and can
Operate at higher bus speeds. Although DDR2 has twice
StaticRAM This is a type of RAM that holds data without the latency (data access delays) of DDR, it delivers data at
an external refresh as long as it is powered. This is in twice the speed, thereby performing at the same level.
striking contrast with the DRAM which must be refreshed
multiple times in a second to hold its data contents. SRAM Rambus DRAM (RDRAM) It is a proprietary, protocol-
is made of D flip-flops in which the memory cells flip-flop based, high-speed memory technology developed by
between 0 and | without the use of capacitors. Therefore, Rambus Inc. RDRAM can operate at extremely high
there is no need for an extemal refresh process to be frequencies as compared to other types of DRAMs.
carried out Synchronous link dynamic RAM (SLDRAM) This version
The limitation of SRAM is that it occupies more space of SDRAM, not used widely, was basically designed as a
and is more expensive than DRAM, While each transistor on royalty-free, open-industry standard design alternative to
a DRAM chip can store one bit of information, the SRAM RDRAM
chip, on the other hand, requires four to six transistors to
store a bit, This means that a DRAM chip can hold at least 3.6.2 Read-only Memory (ROM)
four times as much data as an SRAM chip of the same size,
thereby making SRAM much more expensive. ROM refers to computer memory chips containing
permanent or semi-permanent data. Unlike RAM, ROM is
However, SRAM is faster, more reliable than DRAM,
non-volatile; that is, the data is retained in it even after the
and is often used as cache memory. SRAM chips are
also used in . houschold appliances, and handheld computer is tumed off.
Most computers store critical programs like the basic
electronic devices.
inpuVoutput system (BIOS) in ROM, which is used to boot
Dynamic RAM This is the most common type of memory up the computer when it is tumed on. The BIOS consists
used in personal computers, workstations, and servers of a few kilobytes of code that tells the computer what to
today. A DRAM chip contains millions of tiny memory do when it starts up, such as running hardware diagnostics
cells. Each cell is made up of a transistor and a capacitor, and loading the operating system into the RAM, Morcover,
and can contain | bit of information—0 or 1. To store ROMs are used extensively in calculators and peripheral
a bit of information in a DRAM chip, a tiny amount of devices such as laser printers, whose fonts are often stored
power is put into the cell to charge the capacitor. Hence, in ROMs.
42 Computer Fundamentals and Programming in C
Originally, ROMs were read-only. So, in order to 3.6.3 Finding Required Data from Main
update the programs stored in them, the ROM chip had to
Memory
be removed and physically replaced by another that had
4 newer version of the program. However, today ROM The main memory is organized as a matrix of bits, as
chips are not literally read-only, as updates to the chip shown in Figure 3.2. A matrix of bits means a combination
are possible. The process of updating a ROM chip is a of rows and columns that stores a bit. The main memory,
bit slower, as memory must be erased in large portions which holds the user’s data and programs for execution by
before it can be rewritten. Rewritable ROM chips include the CPU, is directly or
PROMs, EPROMs, and EEPROMs. indirectly connected to
the processor via a bus
Programmable read-only memory (PROM) It is also
called one-time programmable ROM, and can be written
There are two buses, an
to or programmed using a special device called a PROM address bus and a data
bus. The CPU first sends
programmer. The PROM programmer uses high voltages
a number through the
to permanently destroy or create internal links (fuses or
address bus,
anti-fuses) within the chip. The working of a PROM is
similar to that of a CD-ROM recorder, which enables the This number denotes
the memory address
users to burn programs onto blank CDs, The recorded
or the burnt data can be read multiple times. Therefore, of the desired location
programming a PROM is also called burning, just like
of data. Then it reads
burning a CD-R, and is comparable in terms of its
or writes the data itself
using the data bus. Figure 3.2 Bit matrix
flexibility.
Erasable programmable read-only memory (EPROM) It
is a type of ROM that can be erased and re-programmed. ED SECONDARY STORAGE DEVICES
The EPROM can be crased by exposing the chip to strong
ultraviolet light, typically for 10 minutes or longer, and Secondary storage (also known as external memory or
can then be rewritten with a process that again needs the auxiliary storage) differs from main memory in that it is
application of a higher voltage. Repeated exposure to not directly accessible by the CPU. The secondary storage
ultraviolet light wears out the chip. The EPROM is much devices hold data even when the computer is switched off.
more useful than PROM and can be compared with a An example of such a device is the hard disk.
reusable CD-RW. The computer usually uses its input/output channels to
Electrically erasable programmable read-only memory access data from the secondary storage devices to transfer
(EEPROM) Itis based on a semiconductor structure similar the data to an intermediate area in the main memory.
to the EPROM, but allows the entire or selected contents Secondary storage devices are non-volatile in nature,
to be electrically crased, then rewritten electrically, so that cheaper than the primary memory, and thus can be used
they need not be removed from the computer (or camera, to store huge amounts of data, While the CPU can read
MP3 player, ctc,). The process of writing an EEPROM is the data stored in the main memory in nanoseconds, the
also known as flashing. data from the secondary storage devices can be accessed
The flash memory is also a type of EEPROM in which in milliseconds.
the contents can be erased under software control. This is The secondary storage devices are basically formatted
the most flexible type of ROM, and is widely used to store according to a file system that organizes the data into files
BIOS programs. It is primarily used in memory cards, and directories. The file system also provides additional
USB flash drives, MP3 players, personal digital assistants information to describe the owner of a certain file, the
(PDAs), laptop computers, digital audio players, digital access lime, the access permissions, and other information.
cameras, and mobile phones. The EEPROM blurs the
difference between read only and read—write. However, the 3.7.1 Offline Storage
EEPROM is rewritten only once a year or so, compared to
Offline storage devices are those on which data is
real read-write memory (RAM), where rewriting is often
recorded and then physically removed or disconnected
done many times per second.
(off the computer, hence the name). Such devices include
magnetic tapes, floppy disks, optical disks, flash memory
devices, and external hard disks, In order to access data
(a) By applying write protection,
some types of from an offline storage device, it must first be connected
reprogrammable ROMs may temporarily become to a computer.
read only memory. Offline storage devices are widely used to store a
(b) In practice, both RAM and ROM support random backup of important data. For example, if the original
access of memory. data gets destroyed in case of a disaster, the data can be
Computer Memory and Processors 43
recovered from the offline devices, which are usually ofasupply reel, a take-up reel, a R/W head, and an eras€
stored in another distant place. Moreover, offline storage head. When the user has to edit/rewrite the pre-recorded
also provides security of critical data, as these devices are data on a tape, the previously recorded data is erased by
physically inaccessible by a computer, and therefore data the erase head and the new data is recorded. The process
confidentiality or integrity cannot be affected by malicious of recording data is much similar to that of recording on an
software. audio tape or audio cassette
Usage A magnetic tape can store large amounts of
EX) macnetic tapes information and is therefore used in the regular backing
up of hard disks.
Magnetic tapes (shown in
Figure 3.3) are mass storage Advantages
devices capable of backing * Amagnetic tape is compact in size, light in weight, and
up and = retaining =large can store large amounts of data. Therefore, tapes are
volumes of data. A magnetic
easily portable and can be used to transfer data from
tape, which resembles an one computer to another.
audio tape, is a thin stnp of Magnetic tapes are economical. The cost of storing
plastic coated with magnetic characters is very less as compared to other storage
recording material, These
devices.
storage devices are basically
Copying of data on a magnetic tape is easy and fast
used as sequential ac Magnetic tapes can be used for long-term data storage
Figure 3.3 Magnetictape secondary storage devices. and retrieval
Magnetic tapes are available in the form of cassettes, * Tape drives use less power.
reels, and cartridges, with recls being most widely used.
* Tape drives can easily be stored offsite, allowing data
Reels that are used with mini and mainframe computers are to survive even if the computer itself is destroyed or
1/2 inch wide and 2400 feet long. Such a tape can store stolen.
1600 characters per inch of the tape length. This means that
about 50 books could be stored on just one reel of tape.
Disadvantages
Storage capacity of magnetic tape
Data recording density * Length of the tape * Data stored
on the tape can be accessed only sequentially.
* As compared to other storage devices, data on a tape is
Here, data recording density is the amount of data that
accessed at very slow speeds because of serial access,
can be stored on a given length of tape. It is measured * Special hardware is required to read the data stored on
in bytes per inch (bpi), and usually varies from 800 to
tapes, and most standard PCs available today do not
77,000 bpi. For example, a tape of length 2400 feet with come with such hardware.
1000 bpi as its storage density has a storage capacity of + With advancements in technology, hard drives are
2400 * 12 * 1000 = 2,88,00,000 = 28 « 10° =28MB. becoming cheaper than tapes and are therefore being
However, as of now, magnetic tapes with stora: increasingly used for backups.
capacity of up to 35 trillion bytes (terabytes) of data are
Magnetic tapes are casily susceptible to degradation due
easily available in the market to heat, humidity, dust, mishandling, electromagnetic
Data representation On a magnetic tape, data is recorded surfaces, and ordinary wear.
in the form of tiny non-magnetized and magnetized spots, * Magnetic tapes are best suited for full-system restores
where the presence of a spot represents | and its absence and not for restoring of individual files. This is because
represents 0. This means that data is stored in the form of finding and restoring individual files can be a long,
0s and 1s. For example, ‘A’ is stored as 1011 on the tape. slow, and cumbersome process,
Data on a tape is represented using the EBCDIC standard.
However, the data stored on a tape can be accessed only in
a sequential fashion, Unlike magnetic disks, flash drive
EX) Fiopry pisks
optical drives, and floppy drives, magnetic tapes do not Floppy disks (shown in Figure 3.4) are data storage devices
support random access of data.
that consist of a thin magnetic storage medium encased in
On a tape, the data is stored in terms of records, with
a square plastic shell lined with fabric that removes dust
individual records separated by a gap known as the inter- particles. The storage capacity of floppy disks is very
record gap. \n addition, when records are short, they may
limited as compared to CDs and flash drives, Although
be grouped to form blocks. The data stored in the form of
floppy drives are very cheap, they are much slower than
blocks will then have inter-block spacing other data storage devices. Moreover, floppy disks must be
Magnetic tape drive A tape drive is used to read and handled with utmost care as they are vulnerable to damage
write data on a magnetic tape. The tape drive units consist from mishandling. For example, data stored on a floppy disk
44 Computer Fundamentals and Programming in C
can be lost if the disk padding bytes are written on these, which are discarded by
is bended, removed the floppy disk controller.
while in use, or Moreover, each data sector has a header that stores the
exposed to excessive sector location on the disk. An error checking code is also
temperature, dust, or written into the sector headers and at the end of the user
smoke. data, so that the diskette controller can detect errors when
Floppy disks were reading the data.
widely used from the
Storage capacity All 3.5 inch floppy disks are double-
mid-1970s till 2000
sided. They have 80 sectors, 18 sectors/track, and can
to distribute software,
store 512 bytes/sector.
transfer data, and
create backups. Today, Therefore the storage capacity of afloppy disk
Figure 3.4 Floppy disk however, their use has 2 *« 80 * 18 © 512 bytes
become very limited 14,74,560 bytes = 147 MB
Source: Photodisc/OUP Picture Bank
as they have been
superseded by
drives, external hard drives, optical disks, and memory cards.
flash
ERT Hard visks
The mechanism of a floppy disk involves two motors.
While one motor in the drive rotates the diskette at a The hard drive is a part of the computer that stores all the
programs and files, so if the drive is damaged for some
regulated speed, the second motor moves the magnetic
reason, all the data stored on the computer is lost. The hard
R/W head (or heads, if a double-sided drive) along the
disk provides relatively quick access to large amounts of
surface of the disk. To read/write data on the disk media,
data stored on an clectromagnetically charged surface or a
there must be physical contact between the R/W head and
set of surfaces. Today, PCs come with hard disks that can
the disk media. Figure 3.5 shows the internal parts of a
store gigabytes of data.
floppy disk.
A hard disk is basically a set of disks, stacked
Reading/Writing data In order to write data on a floppy together like phonograph records, that has data recorded
disk, current is passed through a coil in the head. The electromagnetically in concentric circles known as
magnetic field of the coil magnetizes spots on the disk tracks
as it rotates. The change in magnetization encodes the A single hard disk includes several platters (or disks)
digital data, that are covered with a magnetic recording medium.
Similarly, to read data from the floppy disk, a small Each platter requires two read/write (R/W) heads, one for
amount of current is induced in the head coil to detect each side. Note that in the figure, all the R/W heads are
the magnetization on the disk. The floppy drive controller attached to a single access arm and so they cannot move
separates the data from the stream of pulses coming from independently. The parts of the hard disk are shown in
the floppy drive, decodes the data, tests for errors, and Figure 3.6,
sends the data on to the host computer system.
Tracks and sectors A blank floppy disk has a pattem of Rw
magnetized tracks, cach broken into sectors. The tracks Arm head Sector
on the floppy drive have some spaces between the tracks Spindle
where no data is written, Similarly, there are spaces Track
between the sectors and at the end of the track to allow Platter
for slight speed variations in the disk drive. Usually some [ff
Cylinder
Shell/Housing b 0&
Magnetic disk (
Shell/Housing
k)Nt fh
Af 0
a aA
SE So
Paper ring
Figure 3.5 Components of a floppy disk Figure 3.6 Schematic diagram of a hard disk
Computer Memory and Processors 45
The R/W head can pivot back and forth over the platters disk drive makes it susceptible to head crash. Head crash
to read or write data on them. Data is actually stored on the can also occur if dust settles into the hard drive, thereby
surface of a platter in sectors and tracks (refer Figure 3.7). resulting in bouncing of the arm when the disk operates.
While the tracks are concentric, sectors on the other hand During a head crash, the fragile magnetic recording medium
are pic-shaped wedges on a track. Thus, a track is divided gets ruined, resulting in loss of the data stored in it. Laptop
into a number of segments (also called sectors) that can users must very carefully move their laptops as moving it
store a fixed number of bytes—for example, 256 or 512 abruptly when it is switched on can lead to head crash.
The tracks are numbered consecutively from outermost to The performance of a hard disk depends on its access
innermost, starting from zero, The number of tracks on time, which is the time required to read or write on the
a disk can vary from 40 on some low capacity disks to disk. Access time is a combination of the following three
several thousands on high capacity disks components:
Seek time This is the time taken to position the R/W head
A sector over the appropriate cylinder (usually around 8 ms on an
average). Seck time varies depending on the position of
the access arm when the R/W command is received. Its
value will be maximum when the access arm is positioned
over the innermost track while the data that has to be
accessed is stored on the outermost track. Similarly, it will
be zero if the access arm is already positioned over the
desired track. On an average, the seck time varies from 10
to 100 milliseconds.
a a A track Rotational delay This is the time taken fo bring the target
sector to rotate under the R/W head. Assuming that the
Figure 3.7 Cross-section of a cylinder hard disk has 7200 rpm, or 120 rotations per second, a
single rotation is done in approximately 8 ms. The average
Moreover, cach platter has the same number of tracks, rotational delay is around 4 ms.
and a track location that cuts across all platters is
called a cylinder. In simple terminology, a cylinder is Transfer time The time to transfer data or read/write to a
vertically formed by tracks. For example, track 2 on disk is called the transfer rate.
platter 0 plus track 2 on platter 1, plus track 2 on platter Thus, the overall time required to access data = seck
n is cylinder 2. The number of cylinders of a disk drive time + rotational delay + transfer time.
is equal to the number of tracks on a single platter of The sum of the seck time and the rotational delay is
the disk also known as disk latency. Disk latency is the time taken
When the computer is turned on, the platters in the hard to initiate a transfer.
disk drive immediately begin to spin. While the platters
in a desktop computer hard disk drive rotate 7200 times
per minute, on the other hand, the hard drives in laptop
The key tousing the hard drive effectively is to
computers usually make $400 rotations per minute (rpm).
minimize
disklatency. Ideally,
thiscan bedone by
You must have heard the steady hum of your hard drive.
defragmentation, which moves related data to physically
Even when you are not retrieving from or writing anything
proximate areas on the disk. Some computer operating
to the hard disk, the platters spin. However, the arm with
systems perform defragmentation automatically,
the R/W head moves only when you run 4 program or
open, save, or delete a file, The arm can move back and
forth across the surface of the platter as many as 50 times To access data from a hard disk, a disk address has to be
in a second. specified. The disk address represents the physical location
of a record on the disk, and comprises the following
components:
* Sector number
Atypical hard disk drive has two electric motors—a disk * Track number
motor to spin the disks and an actuator (motor) toposition * Surface number (when data is recorded on both sides of
the R/W head assembly across the spinning disks. the disk)
The storage capacity of a disk with multiple recording
The R/W head does not actually touch the platters, instead surfaces can be calculated as:
just barely skims above them, supported by a cushion of Storage capacity = No. of recording surfaces * No. of
moving air that is generated by the spinning of the platters. tracks per surface * No. of sectors
The rapid motion of the platters and heads inside the hard per track * No. of bytes per sector
46 Computer Fundamentals and Programming in C
* They can store large amounts of data. If required, the External hard disks are also called removable hard disks.
users can have multiple disks
* The cost of data storage is very low. With advancement
in technology, the cost of magnetic disks has reduced
and the capacity of data they can store has constantly OPTICAL DRIVES
increased.
Data transfer rate of magnetic disks is much higher than Optical storage refers to storing data on an optically
that of the magnetic tapes. readable medium by making marks in a pattern that can
be read using a beam of laser light precisely focused on a
Disadvantages spinning disk. Optical storage devices are the most widely
used and reliable storage devices, The most popular
* They must be stored in a dust-free environment optical storage devices are CD-ROM, DVD-ROM,
* They are larger in size and heavier in weight when CD-Recordable, CD-Rewritable, ete
compared to flash drives and optical disks. Today, every computer contains a CD-ROM drive.
A single CD can hold a large amount of data, including
software, movies, and songs. While some optical storage
EREB EXTERNAL HARD DISKS media is read-only, others are read- and write-enabled
An optical storage media consists of a flat, round,
As the name suggests, an external hard disk (sce Figure portable metal disk, which is usually 0.75 inches in
3.8) is a drive that is located outside the computer case diameter and less than sith of an inch thick. The disk is
in its own enclosure, It is used in addition to internal coated with a thin metal, plastic, or other material that is
hard drives to store data. It has become quite popular highly reflective.
because of its portability and high-storage capacity. It The optical disk stores information in the form of pits
is connected to the computer system with a high-speed and lands (shown in Figure 3.9). Pits are tiny reflective
interface cable, usually with plug-and-play interfaces bumps created with a laser beam and lands are flat areas
such as USB or FireWire, and may also contain a fan for separating the pits. While a land reflects the laser light and
cooling. While with USB connections, data can move at is read as binary digit |, a pit on the other hand absorbs the
arate of 12 to 480 Mbps (megabits per second), FireWire light and is read as binary digit 0.
Computer Memory and Processors 47
0000000000 10000000000 10000000000, rates (or speeds) ranging from 48X to 75X, or more. Here;
a 48X drive has a data transfer rate of 7200 kbps (i.c., 48 *
150 =7200) or 7.2 Mbps.
3.12.2 DVD-ROM
Digital video disk or digital versatile disk (DVD) is an
extremely high-capacity optical disk with storage capacity
ranging from 4.7GB to 17GB. DVDs are widely used to
store large databases, movies, music, complex software, ctc
Figure 3.9 Pits and lands Most of the DVD-ROMs are double-sided disks,
as they can store data on both the sides of the disk
Similar to magnetic disks, optical disks also have tracks Although 4 DVD-ROM resembles a CD-ROM in size
that are divided into sectors, but the shape of these sectors and shape, it stores information in different manner. A
is different from that of magnetic disks. Different types of DVD-ROM drive is compatible with CD-ROM drives
optical storage devices are explained in this section. and can therefore read CDs
A standard DVD can store seven times more data than
3.12.1 CD-ROM a CD because of its multi-layer storage technique and the
fact that the size of its pits and tracks is smaller. When
Compact disk read only memory (CD-ROM), shown data is recorded on a DVD, the laser starts on the inside of
in Figure 3.10, is a type of optical disk that uses laser the disk and moves outward, The laser beam has a smaller
technology to read and write data onto the disk. A single wavelength and can be focused on two different layers
CD-ROM can store a large amount of data, but once the on the disk. Data can be recorded on cach of the layers,
information is stored on it, it becomes permanent and thereby doubling the storage capacity of the disk.
cannot be altered. This means that the stored information In a double-sided DVD-ROM, two such disks are stuck
can only be read for processing, hence the name. back-to-back to allow recording on both sides, However,
such DVD-ROMs must be handled very carefully, as
both sides have data stored on them and this data can be
damaged accidentally due to mishandling
3.12.3 CD-R
Compact disk recordable (CD-R) is a blank disk that can be
used to store information. For example, users can use it to
store their databases, software, projects, assignments, etc
The process of writing data on the optical disk is called
Figure 3.10 CO-ROM burning. CD-R can be used in any CD-ROM drive and
Source: \talianphoto/Shutterstock/OUP Picture Bank is functionally equivalent to a pre-recorded CD-ROM.
However, once data is written on the CD-R, it cannot be
CDs are easily portable from one computer to another and changed. Moreover, the user can continue to store data
are therefore used to transfer data from one computer to on other parts of the disk until it is full. However, cach
another (similar to a floppy disk). The storage capacity part of a CD-R can be written only once and can be read
of a CD-ROM varies from 650 MB to 1GB, which is many times.
1000 times greater than that of afloppy disk. Nowadays, Today, many utility programs are available in the
most software products (such as Microsoft Office, market to write data on CD-Rs, but the most popular and
Windows operating system, and so on) are available on commonly used software for PCs is Nero Burning ROM.
CD-ROMs. CD-Rs are widely used to backup critical data, However,
to record information on a CD-R, the user must have a CD
CD-ROM drive The CD-ROM drive is used to read the writer. A CD writer or recorder (or simply CD-R drive)
information stored in a CD-ROM. The data transfer rate can also read information from a CD. The speed of these
of the first CD-ROM drive was 150 kbps (kilobytes per drives is up to 48X or more, and they are more expensive
second), and is denoted as X. The data transfer rate of a than ordinary CD-ROM drives.
CD-ROM is much slower than that of a typical hard disk
drive, which reads data at a rate of S—15 mbps (megabytes
per second), The speeds of all CD-ROM drives are
3.12.4 CD-RW
calculated relative to the first CD-ROM drive's speed. For Compact disk rewritable (CD-RW) is a new generation of
example, the CD-ROM drives used today have transfer erasable optical disks. The user can write and overwrite
48 Computer Fundamentals and Programming in C
Brand and product promotion The casy availability of recommended when repairing a virus-contaminaléd
inexpensive flash drives has motivated companies to use host computer as there is a risk of infecting the USB
them for promotional and marketing purposes, particularly flash drive itself
within techni and computer-industry circles. USB * Flash drives are very small devices that can casily be
flash drives may be given away for free, sold at less than misplaced, left behind, or otherwise lost. This can at
wholesale price, or included as a bonus with another times be a serious problem, especially if the data is
purchased product. Usually, such drives are stamped with sensitive.
4 company’s logo, as a form of advertising. The drive may * The cost per unit of storage of a flash drive is higher
cither be empty or preloaded with graphics, documentation, than that of hard disks.
web links, Flash animation or other multimedia, and free
or demonstration software. ERTB memory carps
Backup Many users (especially involved in business)
use flash drives as a backup medium. However, one must A memory card (sometimes
remember that it is casy lose them and easy for people called aflash memory card ora
without a right to the data to make illicit copies. storage card, shown in Figure
Newer flash drives have much higher estimated 3.12) is a small device that can
lifetimes and are therefore available with warranties store digital files. They are
of five years, or more, Moreover, flash drives have easily portable from one place
experienced an exponential growth in their storage to another. A user can take a
capacity over time (following the Moore's law growth memory card, insert it into
curve). Today, flash drives of 256 GB are not uncommon. a computer, store files such
This has made them a very good substitute for magnetic Figure 3.12 Memory text documents, pictures,
disks, card audio files, and video file
and then remove the card and
Source: \tya Akinshin/
Advantages take it to another computer
Shutterstock/OUP Picture
Bank
where it can be again inserted
* Data stored on flash drives is impervious to damages
to copy the files onto the local
due to scratches and dust. disk of that computer,
* Flash drives are mechanically very robust and Technically, a memory card uses flash memory, which
computers these days come with a USB port, so they enables the users to add/delete files multiple times.
can be easily used to transfer data from one computer
Initially, when flash cards were first introduced in the
to another
market, they were not very large and were incredibly
* Flash drives have higher data capacity than any other
expensive. However, with advancements in technolog’
removable media.
memory cards have become cheaper and smaller in size.
* Compared to hard drives, flash drives use very little
Today, different types of memory cards are available in the
power and have no fragile moving parts
market. These include compact flash memory (which is the
* Flash drives are small and lightweight devices.
largest in size but has the smallest capacity to store data),
* Operating systems can read and write to flash drives
secure digmemory card (SD), miniSD card, microSD card,
without installing device drivers
memory stick, and the multimedia card (MMC). As these
* Specially manufactured flash drives have a tough
cards have evolved, they have become smaller in size and
rubber or metal casing designed to be waterproof and
larger in data capacity
virtually unbreakable. The data stored in these flash
Most of these cards have constantly powered non-
drives does not get destroyed even when submerged
volatile memory, which means that data is retained on thes
in water. Leaving such a drive out to dry completely
cards even when there is no power supply to the computer,
before allowing current to run through it has been and they do not need to be periodically refreshed. Memory
known to salvage the drive, with no further problems cards have no moving parts; therefore, they are unlikely to
in the future. suffer from mechanical difficulties.
Disadvantages Since newer memory cards are smaller, require |
power, have higher storage capacity, are completely
* Flash drives can sustain only a limited number of write silent, are less prone to mechanical failures, allow
and erase cycles before the drive fails. Therefore, flash immediate access to data, and are portable among
drives are usually not a good option to run application a greater number of devices, they are being widely
software or operating systems. used in the production of an increasing number of
* Most flash drives do not have a write-protect mechanism small, lightweight, and low-power devices, Although
to prevent the host computer from writing or modifying memory cards are far better than hard disks, they still
data on the drive. Wnite-protection devices are highly cannot replace them, because memory cards are quite
50 Computer Fundamentals and Programming in C
¢xpensive. For example, a compact flash card with one or more tape drives. As
192 MB capacity typically costs more than a hard drive shown in Figure 3.14, a tape 1
with a capacity of 40GB. library consists of a number of
slots to hold tape cartridges, a
ERER Mass STORAGE DEVICES barcode reader to identify tape
cartridges, and an automated
Mass storage refers to storing enormous amounts of data method called robot for
in a persistent manner, Mass storage devices can store up loading the appropriate tape
to several trillion bytes of data and hence are used to store on one of the tape drives for
large databases, such as the data of customers of a big retail processing. After processing,
chain and library transactions of students in a college. the robot automatically returns
Figure 3.14 Automated
Mass storage devices have the following advantages: the tape to the library.
Tape libraries can store
tape library
ainable transfer speed
* Low cost large amounts of data ranging from 20 terabytes to more
than 411 petabytes of data. They offer a cost-effective
* High data sto: wwe capacity
* Less weight
solution to the problem of storing large volumes of da
* Better tolerance of physical stress caused by shaking or
with the cost per gigabyte being at least 60 per cent less
dropping
than when using most hard drives. In addition, multiple
drives also lead to improved reliability because even when
+ Low power consumption
+ Easily portable one of the drives fail, the unit can still continue to function
with the other devices at a slower speed.
All these features make it convenient to use them with Though tape drives provide systematic access to
mobile phones, laptops, and desktops. Some of the very large quantities of data, the access is slow, varying
commonly used mass storage devices are discussed in this from several seconds to several minutes. A tape library
section. is commonly used for data backups as the final stage of
digital archiving. In organizations, it is extensively used
3.15.1 Disk Array for recording daily transactions or data auditing
A disk array, commonly known as a redundant array of
independent disks (RAID), is a group of one or more 3.15.3 CD-ROM Jukebox
physically independent and high-capacity hard disk
ACD-ROM jukebox, also known as an optical jukebox,
drives, which can be used in place of larger, single disk
an optical disk library, or a robotic drive, is a data storage
drive systems. The benefit of such a system is that it helps
reduce costs, because having several medium-sized hard device that can automatically load and unload optical
disks such as CDs and DVDs to provide terabytes and
disks is cheaper than having a single large hard disk
petabytes of tertiary storage (Figure 3.15). It can have
As shown in Figure 3,13, a disk array contains several
up to 2000 slots for disks and usually has a robot that
disk drive trays to improve speed and increase protection
traverses the slots and drives for loading the appropriate
against loss of data, The storage capacity of a disk armay is
several terabytes
(1 terabyte = | trillion bytes), The disk array
CD-ROM. After processing, the robot automatically
unit allows data to returns it back to the library
CD-ROM jukeboxes are extensively used for creating
be read or written to
any disk in the array.
backups and in disaster recovery situations, They can be
Disk armys are a
used for archiving data
(data is stored on media
vital component of
that will last up to 100
high-performance
years). Such archival
storage systems, and
their importance is
data is usually written
on disks of write once,
continuously growing
read many (WORM)
with the increase in
type so that it can never
demand to access
information for the be erased or changed.
Moreover, jukeboxes
day-to-day operation
are effectively used
Figure 3.13 Disk array of modem businesses.
for archiving data in
systems such as online
3.15.2 Automated Tape Library digital libraries, online
An automated tape library, also known as a fape silo, tape encyclopacdia, and
robot, or tape jukebox, is a storage device that contains online museums Figure 3.15 CD ROM jukebox
Computer Memory and Processors 51
DATA BACKUP
Data backup is the process of making one or more copies accidental deletion of a file, or a natural disaster like an
of data from an online storage device (hard disk) to a earthquake. In such cases, re-creating all the files would
tertiary storage device like a magnetic tape. The copy of take a lot of time, and at times, it might not even be
data acts as an offline storage so that if the system loses possible. Therefore, it is a good practice to take regular
the original data, it can be retrieved from the backup data backups so that the data can be retrieved within a
device and restored in the online storage device. short time. There are two types of data backups, which
The online storage system may lose its data because of can be compared as follows:
a disk crash, a virus attack, a hardware malfunction, an
* It copies allthe data on a teniary device, * Ncopies only newly created files or files
* The process takes from few minutes to hours changed since the last backup.
* Itis an expensive process interms of both * Bnceds fess backup time and storage space.
lime taken and storage space occupied. © Mis faster.
© Ibs slower. * is complex when compared to full
* It is simple. data backup
the variations in speed is that personal or minicomputers architecture is like having two separate processors installed
use a single processor to cxecute instructions, whereas in the same computer. However, since the two processors
mainframes and supercomputers employ multiple processors are actually plugged into the same socket, the connection
to speed up their overall performance. between them is faster. Ideally, such processors must be
twice as powerful as a single-core processor, but in practice,
3.16.7 Pipelining and Parallel Processing their performance is only about one-and-a-half times more.
Computers working on high-end applications, such as
Most of the modern PCs support pipelining, which is a artificial intelligence and weather forecasting, go a step
technique with which the processor can fetch the second further by implementing the concept of massively parallel
instruction before completing the execution of the first processing, that is, large-scale parallel pro ing. Ino
instruction. Initially, a processor had to wait for an multi-core processor, tens or hundreds of processors are
instruction to complete all stages before it could fetch the incorporated in @ single chip. Companies such as IBM,
next instruction, thereby wasting its time. However, with AMD, and Intel have already come out with multi-core
pipelining, processors can operate at a faster pace as they no chips for desktops, laptops, and servers, These multi-core
longer have to wait for one instruction to complete before chips are available as dual core (2 processors per chip),
fetching the next instruction. Such processors that can quad core (4 processors per chip), 8 core, and 16 core.
execute more than one instruction per clock cycle are called
superscalar processors. Instruction execution without
pipelining and with pipelining are shown in Figure 3.20.
Since multi-core processors generate less heat and
With superscalar architecture, processors could
consume less power, they are also called energy-efficient
execute programs faster by replicating components
like ALUs. Replication was the only possible solution ‘OF power-aware processors.
because a single processor was already made to work at
3.16.8 Types of Processors
its maximum limit
The other technique to enhance a computer's A computer is a combination of hardware and software.
performance is to have parallel processing. With this However, companics often argue about the role that
method, multiple processors can be used simultancously hardware and software should play in the design of
to execute a single program or task, In parallel processing, processor architecture, Companies like Intel want the
a complex and large task is divided into smaller tasks in hardware to bear more responsibility than the software
such a way that cach task can be allocated to a processor. so that the software can be simple and casy; companics
Thus, multiple processors work together simultaneously like Apple, on the other hand, want the software to lead.
on the sub-parts of the task assigned to them, Based on these entirely contrasting opinions, there are two
Parallel processing systems need 4 special software to major processor architectures—complex instruction set
determine how the problem will be divided and then, at computer (CISC) and reduced instruction set computer
a later stage, how the sub-solutions will be combined to (RISC)
form the final solution of the problem.
Modern-day PCs implement parallel processing by using Complex Instruction Set Computer
dual-core processors or multi-core processors. Dual-core
Intel's hardware-oriented approach has given rise to CISC
architecture in which more complexities have been added
in the hardware to allow the software to be simpler, In
CISC machines, most of the instructions are implemented
using hardware. The hardware in such machines is capable
of understanding and executing the instructions. For
example, in a CISC machine, when multiplication needs
to be performed, the programmer just has to write the
Instruction | name of the instruction and its operands (¢.g., MUL 2, 3).
The processor will automatically load the data values in
Instruction 2 processor registers, multiply them in the execution unit,
and store the result. The advantages of CISC processors
Instruction 3 include the following
* Programs can be very simple and short,
Instruction 4 * Short programs require less memory space.
* Less effort is required by the translator (discussed
in Chapter 6) to convert the program into machine
(b) Machine cycle (with pipeline) language
Figure 3.20 Instruction execution with and without pipelining * Faster execution of instructions is possible.
Computer Memory and Processors 55
However, on the downside, CISC machines require companies to decide on the efficient use of space on W
additional hardware circuitry to handle instructions. microprocessor.
This adds to the complexity and cost of the processor's Although RISC machines are less complex and less
hardware circuitry. Therefore, CISC processors are more expensive, they place extra demand on programmers to
expensive than RISC processors. implement complex computations by combining simple
instructions. Unlike CISC machines, programs developed
for RISC machines have more lines of code. Therefore,
they require more memory space and more effort from a
Majorityof the PCs use CISC processors.
translator to convert the code into machine language.
* Pipelining is a technique with which the processor can * In parallel processing, multiple processors can be used
fetch the second instruction before completing the simultaneously to execute a single program.
execution of the first instruction.
>
GLOSSARY
Basic input output system (BIOS) Program that tells Offline storage Data storage device on which the data Is
the computer what to do when it starts up, e.g., running recorded and then physically removed or disconnected
hardware diagnostics and loading the operating system (off the computer). For example, magnetic tapes, floppy
into RAM. disks, optical disks, flash memory, and external hard disks.
Cache memory An intermediate form of storage between Optical storage Storing data on an optically readable
the ultra-fast registers and the RAM. medium by making marks in a pattern that can be read
Computer memory An internal storage area in the using a beam of laser light precisely focused on a spinning
computer used to store data and programs either disk. The most popular optical storage devices are
temporarily or permanently. CD-ROM, DVD-ROM, CD-R, and CD-RW.
Data transfer rate The time taken to transfer data or the Primary memory It is also known as main memory or
time taken to read/write to a disk. internal memory; the only type of memory that Is directly
Disk latency The sum of the seek time and the rotational accessed by the CPU, which continuously reads and
delay. It is actually the time taken to initiate a transfer.
executes instructions stored in the primary memory.
DRAM A type of RAM that must be refreshed multiple Programmable read-only memory A type of ROM that
times in a second to retain its data contents. can be programmed using high voltages,
Erasable programmable read only memory A type of Rotational delay The time taken to bring the target sector
ROM that can be erased and re-programmed. The EPROM to rotate under the R/W head
can be erased by exposing the chip to strong ultraviolet Seek time The time taken to position the R/W head over
light. the appropriate cylinder.
Flash memory A type of EEPROM in which the contents SRAM A type of RAM that holds data without an external
can be erased under software control. The most flexible refresh as long as it is powered. It is made of D flip-flops in
type of ROM. which the memory cells flip-flop between 0 and 1 without
Hard disk A set of disks stacked together like phonograph the use of capacitors.
records, which have data recorded electromagnetically in Superscalar processors Processors that can execute more
concentric circles known as tracks, than one instruction per clock cycle.
Instruction set A set of commands that instructs the System clock A small quartz crystal circuit that controls
processor to perform specific tasks. the timing of all operations within the computer system.
EXERCISES
Fill in the Blanks is a one-time programmable ROM
1, The memory holds data and programs that are 8. The flash memory is also a type of
currently being executed by the CPU. 9. Digital cameras and mobile phones have
2. memory is volatile. memory.
3, memory stores data or instructions 10, The number of cylinders of a disk drive is equal to the
permanently. number of
4. are the fastest of all forms of computer data 11. The process of writing data to a optical disk is called
storage.
5. Aprocessor register can store _ bytes. 12. The most popularly used software for writing data on
6, Static RAM is made of CDRsis_
‘Computer Memory and Processors 57
13. Data on a magnetic tape is represented using the (a) MAR (b) program counter
code (c) MBR (d) IR
| are concentric circles and _ are pie- 8. The speed of supercomputers is specified by
shaped wedges on a track.
{a) GHz (b) GIPS
15. The time taken to R/W data to a disk is called
(c) GFLOPS (d) all of these
16.____ unit directs and coordinates the computer
operations.
State True or False
17. Intermediate results during program execution are
1. Primary memory is faster than secondary memory.
stored in
2. Cache memory is made of ORAM
18. stores the address of the data or instruction to
3, L2 caches are built into the motherboard outside the CPU.
be fetched from memory.
4. An SRAM chip can hold more data than a DRAM chip of
19. Aninstruction consistsof and
the same size.
20. The instruction cycle is repeated continuously until
5. EPROM can be erased by exposing the chip to strong
ultraviolet light.
21. Buses in a computer system can carry
a 6. PROM allows its entire or selected contents to be
electrically erased
22. Inan instruction, specifies the computation to
7. Seek time is the time taken to bring the target sector to
be performed.
23. A: is the smallest unit of time in which
rotate under the R/W head.
processing is done.
8. CD-Rs can be written only once and can be read as many
times.
24. The speed of PCs and minicomputers is specified in
OF 9. Operating systems can read and write to flash drives
without installing device drivers
25. Gigais and tera is =
10. Memory cards use flash memory to store data.
26. processors are power-efficient processors
11. The ALU initiates action to execute the instructions,
12. The value stored in the program counter is copied from
Multiple-choice Questions
the MAR
1. The memory used by the CPU to store instructions and
data that are repeatedly required to execute programs 13. The program counter stores the address of the next
to improve overall system performance is instruction to be executed
14. The executing unit provides functions for data transfer.
(a) primary memory (b) auxiliary memory
15. A processor can perform all operations in a single clock
(c) cache memory (d) flash memory tick,
2. Magnetic tapes, floppy disks, optical disks, flash memory,
16. Computers can have at most one clock.
and hard disks are examples of
17. The speed of a mainframe computer is measured in MHz
(a) primary memory (b) auxiliary memory or GHz.
(c) cache memory (d) flash memory 18. Personal computers support pipelining.
3. The time taken to initiate a transfer is called 19. Pipelining needs replication of components
(a) seek time (b) rotational delay 20. Parallel processing can be implemented only on server
(c) data transfer rate (d) disk latency machines.
4. Disk address is specified using 21. In RISC machines, most of the instructions are
(a) sector number (b) track number implemented using hardware.
22. An instruction set can be implemented only using an
(c) surface number (d) all of these
opcode.
5. The memory used in MP3 players, PDAs, laptops, and
digital audio players is Review Questions
(a) primary memory (b) optical memory 1. What do you understand by computer memory?
(c) cache memory (d) flash memory 2. Differentiate between primary memory and secondary
6. The component of the processor that controls the flow memory.
of data through the computer system is 3. Give the characteristics of the memory hierarchy chart.
(a) BIU (b) execution unit 4. What is a BIOS? Which kind of memory is preferred in it,
(c) CU (d) ALU and why?
7. While transferring data from memory into the processor, 5. Differentiate between static RAM and dynamic RAM
the register that is used as an intermediate placeholder 6. Give the organization of computer memory. How does
of the data is the CPU access a memory cell?
58 ‘Computer Fundamentals and Programming in C
7. Explain the working of a magnetic disk. What do you understand by re-programmable ROM
8. How is data stored on optical storage devices? chips?
9. A DVD-ROM can store more data than a CD-ROM of the Discuss the different types of optical storage devices.
same size. Comment. Draw and explain the basic architecture of a processor.
10. What is a USB flash drive? ‘Control unit is the brain of the computer.’ Justify.
11. Write a short note on memory cards What are special-purpose registers?
12. Give the formulas used to calculate the storage capacity Define instruction cycle.
of magnetic disks, floppy disks, and magnetic tapes. Differentiate between pipelining and parallel processing.
Which of these have the highest storage capacity? How can pipelining improve processor performance?
Explain with the help of relevant examples. What are multi-core processors?
13, What is a head crash? How does it occur? Differentiate between RISC and CISC.
14. Briefly discuss the importance of cache memory.
>: _ _ Number Systems and
‘Computer Codes
TAKEAWAYS
* Number systems * BCD © Weighted codes
* Binary number system * ASC © Gray code
* Octal number system * EBCDIC * Unicode
* Hexadecimal number system * Excess code
Here, 123=1* 100+2*10+3*1 Step3: Repeat Step 2 until all the bits have been
or 123=1 10? +2 10'+3 = 10° Step4: Add the end result of each worked power of 2 to
The same concept is applicable to the binary number get the decimal number.
system, the only difference being that wherever 10 is used,
it is replaced by 2 as shown in Table 4.5.
4.3.2 Converting aDecimal Number into
4.3.1 Converting a Binary Number into
Binary Form
Decimal Form
To convert a decimal number into its binary equivalent,
In a binary number, all the columns are powers of 2. simply divide the decimal number by 2 and then write
Table 4.5 shows the five least significant digit place holders. down the remainder, repeat this process until the number
cannot be divided by 2 anymore,
Five leastsignificant
digitplaceholders
Example 4.4
(‘Sixteen's Eight’s Four's Twos One's i"
column | column | column | column | column (LSB) | Convert decimal 13 of (13),q into its binary equivalent.
2 oe || 2 Solution
2,13 |R
21641
Note that, in Table 4.5, all the columns are specified in 2 | 3 | 0 Now write the result starting from the
powers of 2. Hence, in order to convert a binary number
into its decimal equivalent, multiply that place holder value 2 | 1 [| 1 last remainder obtained, Therefore, (13),o =
(power of 2) with the bit, and then add all the products. 10} 1 (1102),
—___——
Example 4.2
Example 4.5
Convert 1101 into a decimal number.
Solution Convert 169 into its binary equivalent.
Use Table 4.5 to form the decimal number. Solution
Decimal number = 1x 27412? +0x2!+1x%2° 21 169|R
=1x8+1x44O0x2+1x1
2) 8i1
=8+4+0+1
=13 2) 4210
2) 210
24 30/1
21 510
i
2] 211 Nowwrite
the result starting from the last
Convert 1010 1001 into adecimal number.
21110 remainder obtained.
Solution
Decimal number = 1 x 2’ +0 x 2°+ 1% 2° +0 2*+1x2° | 0 | 1 Therefore, (169),,
=(1010 1001),.
+0x2?4+0x 2'+1%2°
=1x 128 +0x64+1x32+0x16+1x8+
Ox4+O0x241x1
4.3.3 Adding Two Binary Numbers
=128+0+32+0+8+0+0+1
=169 Adding binary numbers is similar to the addition of
The following steps summarize the procedure to convert a decimal numbers. While performing binary addition,
binary number into a decimal number. start by adding the bits (digits) in one column at a time,
from right to left as we do in the case of adding decimal
Step 1: Start with the least significant bit (LSB) and multiply numbers. However, to perform binary addition, one must
that bit with 2°. Note that any number raised to O is remember the rules of addition.
always 1,
Step 2: Continue working from right to left. Multiply each Rules of Binary Addition
bit with an incremental power of 2 (i.e., 2°, 27, 2°, + 0+0=0 *0+1=1 -1+0=1
2", ete). + 1+1=0, and carry | to the next more significant bit.
62 Computer Fundamentals and Programming in C
Consider the following examples: be used to restructure the subtraction problem into an
addition problem. This is called subtraction by the two's
0001010 1010101
+ 0100100 + 0101010
complement method.
0101110 Liditit Step 1: To subtract two binary numbers using two's
complement, first find the two’s complement of the
number to be subtracted (subtrahend). Two's complement
i Carry iii Carry is calculated in the following two steps:
1011 1010101
+ 0001 + 0101110
+ Complement cach bit of the number, That is, change |
to 0 and 0 to I. The resultant number is said to be in
1100 _10000011
one x complement form.
+ Add 1 to the resultant number in one’s complement
4.3.4 Subtracting Two Binary Numbers form to get the corresponding two ¥complement
Now that you have learnt to perform addition on two Step 2: Add the minuend and subtrahend (which is now in
binary numbers, subtraction will also be an casy task to two's complement form). Take care of the carries in each
perform. As with binary addition, there are certain rules column, and discard any carry bit that extends beyond
to be followed for binary subtraction. These rules can be the number of bits of the original number or the two's
summarized as: complement
* 0-0-0 *1-0=1 *1-1=0
However, an important point to note here is that when
+ 0—1=0, and borrow | from the next more significant bit subtracting binary values it is important to maintain the
same number of bits for cach number (minuend and
subtrahend). For this, you may pad the number with extra
Note that the value borrowed from the next more zeroes to the left of the value
significant bit depends on the base of the number system You should also remember to discard the carry obtained
and is always the decimal equivalent of the base. Hence, after adding the last bits. Observe the following examples,
in the decimal number system, 10 is borrowed, in binary which will help make the concept clear.
2 isborrowed, in octal 8 isborrowed, and in hexadecimal
16 is borrowed, Example 4.6
Consider the following examples Calculate 1011 — 1001 using two's complement method.
00 Solution
1011 10110111 +001 10
Step 1: Find the two's complement of the subtrahend.
- 1001 00110010 0101010
Subtrahend = 1001
0010 10000101 0101100
One’s complement of subtrahend = 0110
MW Two's complement of subtrahend = 0110 + 1 =0111
00 22 22 Step 2: Add the minuend and the two's complement of
104401 $000101 104401 the subtrahend.
—0011000 1011
~ 0101101 +0111 Now discard the carry from the last bit;
1.0010 hence the result = 0010.
2122
062002
libretto Minuend
1o1olid Subtrahend Example 4.7
OOM Difference
Calculate 10110111 — 00110010 using two's complement
4.3.5 Subtracting Two Binary Numbers Using method.
Two's Complement Solution
Though the previously discussed technique of subtracting Step 1: Find the two's complement of the subtrahend
two binary numbers is simple, there is another way to Subtrahend = 00110010
perform subtraction. In this technique, subtraction is One’s complement of subtrahend = 11001101
done through addition, Do you recall having learnt in Two's complement of subtrahend = 11001101 +1
school that a positive number subtracted from another = 11001110
positive number is the same as a negative number added Step 2: Add the minuend and the two's complement of the
to a positive number? This fundamental concept can subtrahend.
Number Systems and Computer Codes (os
10100 00000
11110 000000
1011000
1100011
111010= 101 = 100100010
4.4.1 Converting an Octal Number into
111010
Decimal Form
«101
111010 Try to recall what we did to convert a binary number into
0000000 its decimal equivalent; the same steps can be applied to
11101000 convert an octal number into decimal. The only difference
100100010 is that we will use base 8 insteadof base 2.
64 Computer Fundamentals and Programming in C
Tn order to convert an octal number into its decimal 8 | 12 | 2 Nowwrite the result starting from the last
equivalent, multiply that place holder value (power of 8) 8 | 1 |4 remainder obtained. Therefore, (786),, =
with the digit, and then add all the products
| 0 | 1 (1422),
Example 4.9 ——
Convert (123), into its decimal equivalent
Example 4.12
Solution
Use Table 4.6 to form the decimal number. Convert (9890), into its octal equivalent
Decimal number = 1 = 8? + 2x 8'+3x8° Solution
=1x64+2x8+3x1 8 |9890 | R
=64+16+3
=83
8 | 1236
|2
8 | 154 | 4
8 | 19 | 2 Nowwrite the result starting from the
8| 2 | 3 _ last remainder obtained
Example 4.10 “|
0 12 Therefore, (9890), = (23242),
Convert (10567), into its decimal equivalent
Solution
Decimal number = 1« 8°+0x8'+5x8?+6x8'+7x8° 4.4.3 Converting an Octal Number into Binary
= 14096 +0*512+5*64+6x8+7x1 Form
= 4096 +0 +320+48+7 To convert an octal number into its binary equivalent,
=4471 replace cach octal digit with its binary equivalent,
The following steps summarize the procedure to convert an
octal number into a decimal number.
Example 4.13
Step 1; Start with the least significant digit and multiply
that digit with 8°. Note that any number raised to 0 Convert (63), into its binary equivalent
is always 1,
Solution
Step 2: Continue working from right to left. Multiply each
digit with an incremental power of 8 (i.e., 8°, 8”, 8°, (63), can be converted into its binary equivalent using the
8', etc.) following steps:
Step 3: Repeat Step 2 until all digits have been multiplied Step 1: Write the binary equivalent of 6, which is equal to
Step 4; Add the end result of each worked power of 8 to 110.
get the decimal number. Step 2: Write the binary equivalent of 3, which is equal to
011
Step 3: Merge the two values. Therefore, (63), = (110011),
Let us take another example and convert (175), Into its
4.4.2. Converting a Decimal Number into binary form.
Octal Form Step 1: Write the binary equivalent of 1, which is equal to
001
To convert a decimal number into its octal equivalent,
Step 2: Write the binary equivalent of 7, which is equal to
simply divide the decimal number by 8 and then write 111
down the remainder; repeat this process until it cannot be
Step 3: Write the binary equivalent of 5, which is equal to
divided by 8 anymore.
101
Step 4: Merge thevalues. Therefore,(175), =(001111101),
Example 4.11
4.4.4 Converting a Binary Number into Octal
Convert decimal 786 or (786);o into its octal equivalent
Form
Solution
8 |786 | R To convert a binary number into its octal equivalent, divide
the binary number into groups of bits, where cach group
8 | 98 | 2 consists of exactly three bits (except the last). Convert
Number Systems and Computer Codes 65
Since 2 is less than 8, Since 4 is less than 5, ones. Then, working from right to left, we move to a 16's
we borrow I from the we borrow | from the column, a 256’s column, a 4096's column, a 65,536's
next immediate digit. next immediate digit column, and so on. In programming languages, prefix ‘Ox*
So 9 now becomes 8. So 7 now becomes 6 is used to indicate a hexadecimal number,
Moreover we get 10, Moreover we get 10.
80 now it's not 2 but so now it’s not 4 but 4.5.1 Converting a Hexadecimal Number into
10 +2= 12. 8 is finally 10 +4 = 14. 5 is finally | Decimal Form
subtracted from 12 and subtracted from 14 and
the result is written. the result is written. To convert a hexadecimal number to decimal, multiply the
value in cach position by its hex weight and add each value
Case 2
You can use the same concept while doing octal Example 4.15
subtraction, When we subtract two octal numbers, there
can be two cases:
Convert 0x3128 into its equivalent decimal value.
Solution
Case 1: The digit in the minuend is greater than the digit
in subtrahend. In this case, we just subtract the Decimal number = 3 x 16° + 1x 167 +2 16° +B x 16°
digits and write the result. = 3x 4096 +1 256+2*16+Bx1
12288 +256+ 32+ 11
Case 2: The digit in the minuend is smaller than the digit = 12587
in subtrahend. In this case, borrow | from the
immediate higher place. When a digit is borrowed,
the minuend digit at the current place gets 8 and Example 4.16
4 | is subtracted from the minuend digit at the
immediate higher place Convert hexadecimal 123 into decimal.
Consider the following examples
Solution
98
3108
Decimal number = 1 x 167 + 2% 16'+3 «16°
7654 Arve =1x256+2*16+3x1
= 256 +32+3
2341 =3654
$313 0334 =291
——
4.5.2 Converting a Decimal Number into
G8 HEXADECIMAL NUMBER SYSTEM
Hexadecimal Form
The hexadecimal number system is the base 16 number To convert a decimal number into its hexadecimal
system. It uses sixteen distinct symbols—the symbols 0-9 equivalent, simply divide the decimal number by 16 and
represent values zero to nine, and A, B, C, D, E, F (or af) then write down the remainder, repeat this process until it
represent values 10-15, Figure 4.2 shows numbers from cannot be divided by 16 anymore.
0 to 15 and their values in binary as well as hexadecimal
number systems. Example 4.17
The main problem with binary numbers is that, for larger
values, binary numbers quickly become too unwieldy Convert decimal 1239 into its hexadecimal equivalent
The hexadecimal (base 16) number system overcomes Solution
this problem, as hexadecimal numbers are very compact
Moreover, it is very casy to convert from hexadecimal to 16 11239 | R
binary and vice versa. 16 | 77 | 7 Nowwrite
the result starting
from the last
In the hexadecimal system, just like in the binary, 16 | 4 | D_ remainder obtained. Therefore, (1239),o
octal, and decimal number systems, we start counting
from the first column, which represents the smallest unit, | 0 14 =(407):6
Figure 4.2. Hexadecimal number system and its binary and decimal equivalents
Number Systems and Computer Codes (a
4: Merge the individual values. Thus, (567), = (101 Case 2: The digit in the minuend is smaller than the digit
110 111);. in the subtrahend. In this case, borrow | from
: Divide the binary number into groups of 4 binary the immediate higher place. When a digit is
bits. (Left pad the binary number
with zeroes if there borrowed, the minuend digit at the current place
are not enough bits to be grouped.) Therefore, gets 16 and a | is subtracted from the minuend
0001 0111 0111 digit
atthe immediate higher place.
Convert each group of binary bits into itsequivalent 15 23
hexadecimal number. Thus, we have 1 7 7. D218 16 EM1I7 7728
Merge the octal values to get the final result. Hence, 6A7B EASO FerD Exe
(567)s = (177)is. 2361 3 A87 -9 676 B3AD
471A ABO9 5 9A7 34DF
Example 4.22
WORKING WITH FRACTIONS
Convert (134), into its hexadecimal equivalent.
Solution In general, for a fractional number a, in any number system
Step 1; Write the binary equivalent of 1, which is equal to of base 4, the position values can be written as:
001.
Step 2: Write the binary equivalent of 3, which is equal to
011.
Step 3: Write the binary equivalent of 4, which is equal to The generalized table when used with specific base
systems can be given as in Table 4.7.
100.
Now let us use Table 4.7 to convert the following
Step 4: Merge the individual values. Thus, (134), = (001
numbers of base 6 into decimal.
011 100),.
Step 5: Divide the binary number into groups of 4 binary 1. Convert (101101110), into decimal:
bits, Therefore, (10110.1110))
=1 *28+0x 2+ 1x 2+1%2'4+0%
0000 0101 1100 Peixrterx2+ 1x 2940x294
Step 6: Convert each group of binary bits into its equivalent = 1X 1G+OKR+1 KAHL 2+OK1+
hexadecimal number, Thus, we have 5C. LX U2+ 1K 14+ 118 +0% 1/16
Step 7: Merge the hexadecimal values to get the final =16+0+4+2+0+05+0.25
+0.125+0
result. Hence, (134), = (5C)
x5.
= 22.875
2. Convert (127.35), into decimal:
4.5.7 Adding Two Hexadecimal Numbers (127.35), = 1 * 8 +2%8'+ 7% 8943x8445 x87
You can add two hexadecimal numbers in the same way
= 16442847143 «145% 1164
as you add decimal and octal numbers. When we add two
= 64 + 16 + 7+ 0.375 + 0.078125
hexadecimal numbers, there can be two cases: = 87.453125
Case 1; The sum is less than 16, In this case, we just write 3. Convert (21 F.DE))« into decimal:
the digit obtained after addition. (QQIR.DE),
5=2* 167+ 1* 16'+F * 16°+D x 16" +
Ex 167
Case2: The sum is greater than or equal to 16. In this =2*256+1* 16415 *1413 *16+
case, 16 is subtracted from the sum and the result 14 * 1/256
is written at that position. Moreover, a carry is =S512+ 16+ 15 +0,8125 + 0,0546875
given to the next digit. = 543.8671875
Consider the following examples:
Now that we have converted a fractional binary/octal/
1 111 111 hexadecimal number into its decimal equivalent, let us learn
1A2B 2C4A 5C8D 6E8C how the fractional part of a decimal number can be converted
+2361 +D287 +9676 +B3AD into its equivalent binary/octal/hexadecimal number.
3D8C FEDI F303 12239
Example 4.23
4.5.8 Subtracting Two Hexadecimal Numbers
Convert the decimal number 92.25 into its equivalent binary
When we subtract
two hexadecimal
numbers there can be number.
two cases: Solution
Case 1: The digit in the minuend is greater than the digit Break the number into two parts. The first part consists
of digits
in the subtrahend. In this case, we just subtract the before the decimal point, and the second part contains digits
digits and write the result. after the point. A separate procedure is applied to convert
Number Systems and Computer Codes 69
Convert 4567), to BCD 2.5. Give the BCD equivalent for the decimal number 68.23.
Solution Solution
From Table 4.9, we can write, From Table 4.9, we can write,
{4567)
x =(0100 0101 0110 0111) scoser: {68.23),9
=(0110 1000.0010
0011Jecpes2t
Number Systems and Computer Codes e
4.8.6 Unicode
ASCII, which is the most widely used encoding scheme, is
a 7-bit code that can support only 128 character definitions.
These 128 characters can be used casily for English
characters, numbers, and punctuation symbols but there is
2421 Code negligible or no support for the characters in other languages
of the world. Therefore, organizations started creating their
The 2421 weighted code has weights 2, 4, 2,and 1. In own encoding schemes for other languages’ characters,
this code, a decimal number is represented using 4 bits. thereby defeating the concept of a universal or standard code
The maximum weight in this code is2+4+2+1=9, for information exchange. Moreover, each new scheme was
Therefore, the 2421 code can represent decimal numbers of different length, and programs were supposed todetermine
from 0 to 9, as shown in Table 4,10. which encoding scheme they would be using.
Similarly,
in the 4221 coding. each digit isrepresented The only solution to this problem was to have a new
as a 4-bit group, and cach bit represents 4, 2, 2, and 1, encoding scheme that could unify all the different encoding
instead of 8, 4, 2, and 1. For example,7 in 4241 can be schemes to minimize confusion between the different
written as 1101, because 1 *4+1*2+0*%2+1*1=7. schemes. This led to the development of Unicode, which
can represent characters (including punctuation marks,
4.9.5 Gray Code diacritics, mathematical symbols, technical symbols, and
The gray code is a minimum change code, in which only arrows) as integers. It has several character encoding
one bit in the code changes from one code to the next. It forms such as the following:
is a non-weighted code. These codes are also known as UTF-8 Thisuses only eight bits t encode English characters.
single-distance codes. This format iswidely used inemail and onthe Intemet.
‘The gray code of a number is obtained from its binary UTF-16 This uses 16 bits to encode the most commonly
code, To derive the gray code of a number, the following used characters.A 16-bit Unicode can represent more
steps are used: than 65,000 characters. Moreover, any Unicode character
+ Copy the MSB of the binary code as the MSB of the represented in the UTF-16 form can be converted to the
gray code, UTF-8 form and vice versa without losing information.
* Repetitively add MSB and the bit next to the MSB to UTF-32 This uses 32 bits to encode the characters.
get the correspondingbit for the gray code. A 32-bit Unicode can represent more than 100,000
For example, letuscalculate the gray code of 7. characters.
Decimal
7=Binary 0111
Now gray code of 7 is obtained as follows:
* MSB of gray code 7 is 0 (because MSB of binary 7 is 0)
Now, other bits can be calculated
© O0+1=1
as:
Da ET
Besides representing the characters of different
+ 1+1 =0(discard the carry) languages, UTF also reserves some codes for private
+ L+1=0 (discard the carry) use, which hardware and software vendors can assign
Hence, gray code for 7 = 0100. internally for their own characters and symbols.
74 Computer Fundamentals and Programming in C
Nowadays, Unicode is widely used to represent text for computer processing, as it provides a consistent way of
encoding multilingual characters. This makes it convenient to exchange text files internationally. The growing popularity
of Unicode suggests that it will eventually supplant ASCII as the standard coding scheme.
Table 4.11 illustrates how coding is done in the ASCII, EBCDIC, XS3, 4221, gray, and Unicode coding techniques.
POINTS TO REMEMBER
* Computers are electronic machines that operate using Binary coded decimal (BCD) is a technique of
binary logic. These devices use two different values to encoding decimal numbers. In unpacked BCD
represent the two voltage levels (OV for logic 0 and SV representation, only one decimal digit is
for logic 1). represented per byte. In packed BCD representation,
* The number of unique digits used to form numbers two decimal digits are stored in a single byte.
within a number system is called radix of that system. ASCII is a 7-bit character code that was introduced
Decimal number system has a radix of 10, binary has a by ANS! and is used by personal and workstation
radix of 2, octal has a radix of 8, and hexadecimal has computers.
a radix of 16. EBCDIC is an 8-bit character encoding technique used
To convert a decimal number into its binary/octal/ on IBM mainframe operating systems. It is considered
hexadecimal equivalent, simply divide the decimal to be an obsolete coding system, but Is still used in
number by 2/8/16 and then write down the some equipment to allow for continued use of
remainder, software written many years ago that requires an
To convert a binary/octal/hexadecimal number into EBCDIC communication environment,
its decimal equivalent, multiply the place holder * In the excess-3 coding technique, each decimal
value by the digit, and then add all the products. digit is the 4-bit binary equivalent with 3 (0011)
Signed number representation is required to encode added.
negative numbers in the binary number system. * Gray code is a minimum change code, in which only
* The two’s complement is the most popular method ‘one bit changes from one code to the next.
of representing signed numbers in the binary
number system.
GLOSSARY
Binary number system It is a number system of base 2 Hexadecimal number system It is a number system of
Bit It is short form of ‘binary digit’; smallest possible unit base 16.
of data; can be either 0 or 1. Nibble It is a group of four binary digits.
Byte It is a group of eight bits. Octal number system it is a number system of base 8,
Decimal number system It is a number system of base 10. Word It is a group of 2 bytes.
Number Systems and Computer Codes 75
EXERCISES
Fill in the Blanks 10. Computers can define a word of four bytes.
1, Computers are electronic machines that operate on
logic. Review Questions
2. bits make one word, 1. What is binary language?
3.0-1 =_ -_ 2. Why do computers understand only binary language?
4. Inthe _____ technique, the MSB is used to denote 3. Explain the process of converting a binary number into
the sign of the number. decimal with an example.
5. In , the digit is stored in the lower nibble, and Describe the general procedure to convert a number
the higher nibble is not relevant to the value of the from any base system into its decimal equivalent. Explain
represented number. using examples the conversion of numbers from any
6, ASCII codes can support characters. three base systems to the decimal system.
7, EBCDICisa__ bit character encoding technique. How can two numbers be subtracted only through
8. The hexadecimal number system uses digits from addition? Explain with the help of an example.
to How are signed numbers represented in the binary
9. The octal number system was used in the _ form?
system. Two's complement is the most popular technique to
10, Working from right to left, the colurnns in the hexadecimal represent signed numbers. Justify the statement.
number system are Differentiate between packed and unpacked BCD
representations.
Multiple-choice-Questions How is the 8421 code different from the 4221 code?
1. The code that is easier to use on punched cards is Give the gray code for the decimal number 13
(a) ASCII (b) EBCDIC Convert the following numbers into the decimal number
system.
(c) Excess-3 (d) BCO
2, The code also known as single-distance code is {a) (1011 0101),
(a) ASCIL (b) EBCDIC (b) (5674),
{c) Excess-3 (d) gray code {c) (A1E2),6
3, The coding technique in which the upper nibble is {d) 0000 1001 (unpacked BCD)
padded with 1111 is (e) 1000 0001 (packed BCD)
(a) ASCII (b) EBCoIC Convert the decimal 987654 into octal and hexadecimal
number systems.
(c) Excess-3 (d) gray code
4, 12345 in octal is_ in decimal. Convert 1001 0010 1110 into the hexadecimal number
system.
(a) 5439 (b) 5349 Convert 89CD into the binary number system.
(c) 4593 (d) 4359 Subtract:
5, 98765 in decimal is in hexadecimal
(a) 10101011 -01111
(a) 1¢81D (b) C1810
(b) 11100001 ~ 11110111
(c) 181¢D (d) C0181
{c) 1010101010 ~ 111101
16. Add:
State True or False
1, Abyte is a group of eight bits. (a) 10101011 + 0111111
2, Bits 4 through 7 form the lower nibble. (b) 11100001 + 1121110111
3. l+1=1 {c) 1010101010 + 111101
4. The two's complement method can be used to 17 Multiply:
restructure a subtraction as an addition problem. (a) 10111 x 1011
. The octal number system uses digits from 0 to 8. (b) 1111000 100
au
. The two's complement of a negative number is obtained
(c) 1121101 * 1111
by negating the bits of its positive counterpart.
18. Divide:
7, In packed BCD representation, two decimal digits are
(a) 10121110/1011
stored in a single byte.
8, ASCII digits are examples of unpacked BCD numbers. (b) 1111000/100
9. ASCII supports more number of characters than EBCDIC. (ec) 1121101301/1111
Boolean Algebra and
~~ ‘Logic Gates
TAKEAWAYS
© Boolean algebra © Truth tables © Universal gates
¢ Venn diagrams * Canonical forms * Karnaugh
map (K-Map)
* De Morgan's
law © Logic gates
VENN DIAGRAMS
A Venn diagram can be used to represent Boolean
operations using shaded overlapping regions. In the Venn x
Yi, x wy
diagrams that are presented in this section, there is one
Figure 5.5 Venn diagrams for double negation law
circular region for cach variable, The interior and exterior
of aregion ofa particular variable corresponds to values 1
(truce) and 0 (false), respectively, The Venn diagrams De Morgan’s
Law: x Oy’ =(x Uy)’
corresponding to AND, OR, and NOT operations are To visualize De Morgan's law, for the left-hand side
shown in Figure 5,3. Here, the shaded area indicates the (LHS), shade the area that is neither in x nor in y. Then, for
value | of the operation and the non-shaded area denotes the right-hand side (RHS), shade the area corresponding to
the value 0, x Uy, which is the area in eitherorboth the circles, Finally,
shade the area that is not in the region of x U y. It canbe
seen from Figure 5.6 that it is the same area that we had
shaded for the LHS.
voy vuy 7 Y
Figure 5.3 Venn diagrams for conjunction (AND),
disjunction (OR), and complement (NOT) ay ny
ZY
Yt
avy leayy
The following points can be observed from Figure 5.3: Figure 5.6 Venn diagrams for De Morgan's law
* For the AND operation, the region common to both
circles is shaded to indicate that x 9 y is | when both
variables are 1, The non-shaded area indicates that x Oy
is 0 for the other three combinations of variables x and y.
TRUTH TABLES
* For the OR operation, the regions that lic inside eitheror
A truth table is used to describe a Boolean function of
both the circles are shaded.
n input variables. It lists all possible values of input
* For the NOT operation, the Venn diagram represents combinations of the function and the output that will
complement x’ by shading the region nof inside the be produced based on these input combinations. Such
circle,
a table provides a useful visual tool for defining the
Venn diagrams are useful to understand and visualize the input-output relationship of binary variables in a Boolean
following laws of Boolean algebra. function.
78 Computer Fundamentals and Programming in C
A Boolean function of'n variables has 2" rows of possible term OR’ed with a | is always | and a term AND‘ed with
input combinations, Each row specifies the output of the a 0 will always result in 0.
Boolean function for a different combination. The truth |. A+0=A
tables for the Boolean operators are shown in Table 5.1 If A = 0, then 0 + 0 = 0, which is equal to A
If A = 1, then 1 +0 = 1, which is again equal to A
Lee Truth tables for Boolean operators 2. At+1=1
| AND OR NOT IfA =0, then 0+1=1
\| a [z=A.8 | 4 |B |Z=AsB 4 |Z=a IfA= 1, then 1 +1=1
jo 0 oy) ww 0 on 8 3. A-0=0
}o a oO” me 1 1 0 IfA = 0, then 0-0 =0.
IfA= 1, then 1 0=0.
|i @ om) Wwe 1
WEEE i Gl 1 4. A*1=A
IfA= 0, then 0+ 1 0, which is equal to 4
IfA=1,then ts 1 1, which is again equal to A
A truth table can also be used to represent one or more
Boolean functions, For example, Table 5.2 represents the 5.4.2 idempotency Law
truth table for the Boolean function Z= 4 U(B OC).
The idempotency law states that a term AND’ed with itself’
or OR’ed with itself is equal to that term
Truth tableforBoolean function 2= AU (8) 1. A+A@A
A la c Ipnc |ZuAs(BUq) If A = 0, then 0 + 0 = 0, which is equal to A
0 0 ) ° ° IfA = 1, then | +1 = 1, which is again equal to A (here,
A + B means a true valuc, that is, a non-zero value),
0 0 1 0 o
2. A*A=A
0 1 0 0 o IfA= 0, then 0° 0 0, which is equal to A
0 1 1 1 1
IfA=1,then ls 1, which is again equal to. A
1 0 0 ° 1
1 0 1 0 1 5.4.3 Complement Law
1 1 0 0 i The complement law states that a term AND'ed with its
\ 1 1 1 ! 1 comple-ment always results in 0 and a term OR'ed with
its complement always results in |
|, A+A'=1
23 Basic LAWS OF BOOLEAN ALGEBRA IfA= 0, thenO+1=1
IfAw@ 1, then 1 +01
The laws of Boolean algebra can be divided into two
2. A-A'=0
categories—laws applicable on a single variable and laws IfA=0, then 0-1 0, which is equal to 0,
applicable on multiple variables (Figure 5.7).
IfA=1, then 1-0 0, which is again equal to 0
Truth table to prove the commutative law Truth table to prove the associative law
of the OR operator of the AND operator
A B A+s B+a A B c 4-(8-C) | (A- Bye
0 o 0 0 o 0 o o 0
0 1 1 1 0 0 1 0 0
1 0 1 i 0 1 0 0
1 1 1 1 o ' 1 0 0
1 0 0 o 0
i 0 ! 0 i}
2. A*B=B-A 1 1 0 0 0
Table 5.4 shows the truth table of the Boolean functions, 1 1 1 i 1
which proves this law
=A BU +C)+A CL +B)
1S: Truth table to prove the second distributive law A+ B+A'C=RHS (Since 1+C=1
ie
is, m/ = M,. It is possible tocheck this, (A’ « BY ' = 4+ B.
Multiply each term with the sum of the missing variable and Therefore, in a maxterm, 0 will be represented in the
its complement. Therefore, un-complemented form and I will be represented in the
FIA, B, C)= AB’ (C+ C’) + BC (A+A')+ AC (8 +8") complemented form.
= AB'C
+ AB'C + ABC + A'BC + ABC + ABC
By looking at the truth table, we can say that the XOR
= AB'C + AB'C’ + ABC’ + A’BC’ (Because A+A=A)
function can be represented as the product of the maxterms
or the canonical POS form as follows:
= 101+ 100+110+010
=me+my+m,_+myz F(A, B)= (A +B)» (A' +B’)
Therefore, the canonical SOP form of the given Boolean expres-
The shorthand
notation is as follows:
sion can be given asfollows:
F(A, B, C)= ms + mg + me + mz oFFIA, B, C)= Em(2, 4, 5, 6) FIA, B) = Mo-My or F(A, B) = TIM(0, 3)
Example 5.2
Let us consider some examples of sum terms and maxterms
for a function of three variables A, B, and C: Convert F(A, B, C)= (A+ B')(8 + C’) tothe canonical POS form.
Sum terms 4,4 + 8, B+ C,A' +B, A’ + BY Solution
Maxterms 4+B+C.A+B'+C,
A+ B+ CA +B +O Add each term with the product of the missing variable and
its complement. Therefore,
A maxterm is represented by a symbol M,, where the
subscript / is the decimal equivalent of the maxterm. For FIA, B, C)= [(A+ B')+ (C- CYB + C) +(A A’)
example, consider the truth table of the XOR operation S(AtB'+C-CYB+C
+A A)
given in Table 5.13 and note the corresponding maxterms. Using the distributive
law, we can write
FIA, B, C)= (A+B + CiA+ B+ CVB+C + Al(B+C +A’)
Truthtable ofXORoperation =(A+ B+ CYA+B'+C}A+B+C)(A'+B+C)
= (010)(011)(001){101)
= (Mz(M3)(M,)(Ms)
Therefore, the canonical SOP form of the given Boolean
expression can be given as
FA, B, C)=M,-M,°M, + M, orF(A,8, C)=NM(1, 2, 3, 5)
LOGIC GATES
Only those input combinations for which the function
produces 0 as the output are considered tofind the product We have seen that computers work on binary digits, which
of maxterms. form the heart of digital electronics. In digital electronics,
It should be noted that for My we have written My = We are not concemed about electrical signals; rather,
A+ B and not A’ + B'. This is because any minterm m, we just need to understand the difference between two
is the complement of the corresponding maxterm M,, that States: on (1) and off (0). Moreover, in digital electronics,
Boolean Algebra and Logic Gates 83
operations are performed using logic gates, which are also gate accepts two inputs and retums 0 if both the inputs areTy
known us Boolean gates. These gates work only on the else retums 1. The truth table of the NAND gate is given in
logic that comprises cither a 0 or 1. There are different Table 5.17, The expression involving a NAND operation can
types of Boolean gate ch of which follows a different be written as Input, |Input), or Input, Input)
set of rules. In this section, we will discuss Boolean gates
and sce how Boolean expressions can be represented using Lo eee® Truth table of NAND gate
these gates in digital electronics.
Input, Input, Output
AND gate The AND gate is represented with the> symbol 0 0 1
This gate accepts two inputs and gives an output. The output
will be | if and only if both the inputs are 1, and will be a 0 0 1 1
otherwise. The truth table of the AND gate is given in Table i 0 1
5.14. The expression involving an AND operation can be 1 1 0)
written as Input) © Input, or Input, «Input,
NOR gate The NOR gate is represented using the 2
LELICEB GR Truth table of AND gate symbol. In addition, it is known as the negated OR“or
Input, Input; Output NO OR gate. It is just the opposite of the OR gate, The
0 0 0 NOR gate accepts two inputs and returns | only if both the
inputs are low (0). The truth table of the NOR gate is given
0 1 0 in Table $,18. The expression involving a NOR operation
1 o 0 can be written as Input;—Inputy, or Input; + Input,
1 1 1
Le Eee Truth table of NOR gate
OR gate The OR gate is represented with the } > symbol Input, Input; Output
This gate accepts two inputs and gives an output. The
output will be | if any of the two inputs is 1. That is, 0 ) 1 |
it gives a 0 output only when both the inputs are 0. 0 1 0 |
The truth table of the OR gate is given Table 5.15. The 1 0 0
expression involving an OR operation can be written as 1 1 0 }
Input, \ Input, or Input, + Input).
XOR gate The XOR gate is represented using the —))-
Cee ee Truth table of OR gate symbol. The X in the XOR gate stands for exclusive, This
Input, | Input; Output means that the output from this gate will be | if only one
| 0 0 0 of the inputs is a 1, but not both. Notice in Table 5.19 that
| 0 1 i the output is a 0 if both the inputs are | or 0. In general, the
output of the XOR gate is | when the number of its high
} 1 0 1 inputs is odd. The expression involving an XOR operation
\ I 1 1 can be written as Input; ® Input. This also means that the
output will be 1 if the inputs are different
NOT gate The NOT gate is represented by the -}e- symbol
Unlike the AND and OR gates, the NOT gate accepts just one if eece Truth table of XOR gate
input, The output produced by a NOT gate is just the opposite
of the input given, For example, if the input is | the output is Input, Input, T Output
0, and vice versa. The expression involving a NOT operation 0 0 0
ean be written as NOT Input, or as ~Input, or as Input’ 0 1 1
Table 5.16 shows the truth table of this gate 1 0 I
1 1 °
Truth table of NOT gate
Input Output XNOR gate The XNOR gate is represented using the ~)>
| 0 i symbol. In addition, it is known as the negated XOR or NO
\ 1 r XOR gate and is just the opposite of the XOR gate. The
XNOR gate accepts two inputs and returns | only if both the
NAND gate The NAND gate is represented using the | > inputs are same and a 0 otherwise. The expression involving
symbol. In addition, it is known as the negated AND or NO an XNOR operation can be written as Input, ® Inputy .The
AND gate. It is just the opposite
of the AND gate. The NAND truth table of the XNOR gate is given in Table 5.20.
84 Computer Fundamentals and Programming in C
pe
(b) OR operation of the first parentheses
0 1 0 ]
' o 0 |
\ It t 1 }
(c) NOT operation
i)
LOGIC DIAGRAMS AND BOOLEAN
EXPRESSIONS
(d) OR operation of the second parentheses
A logic diagram is a pictorial representation of a
combination of logic gatestospecify a Boolean expression.
Therefore, we can directly obtain the Boolean expression
by analysing the circuit diagram or vice versa.
Let us first convert a logic circuit diagram to a Boolean
expression. In order to do this, first list the inputs at the
correct place and then process the inputs through the gates
by considering one gate at a time. Write the output of cach
gate, This will give you the resulting Boolean expression (¢) OR operation of the two parentheses
of cach of the gates. For example, consider the logic circuit
diagram given in Figure 5.9. Let us use this diagram to
obtain its cor-responding Boolean expression.
apt A")
A UJ (A' By +
c
(B+)
(f) Redrawn figure with single inputs of each input variahle
dD
wo (Be C+D EY Figure 5.10 Conversion of Boolean expression into logic
& diagram
pp «Dp
(Figure 5.11).
c
Example 5.6
Figure 5.11 Representation of a NOT gate
Represent Y = (A + 8) -C using logic gates.
using a NAND gate
Solution
Ye(A+B)c
AND Gate
Represent Y = (A 8) + (C- D) using logic gates. Figure 5.12 Representation of an AND gate
using a NAND gate
Solution
Y=(A- B)+(C- D) OR Gate
aos AB An OR gate can be implemented using a NAND gate as
shown in Figure 5.13
>>>
Y=(A-B)+(C-D)
cD
Example 5.8
Figure 5.13 Representation of an OR
Represent Y= (A+B) + C- D+ (E> F) using logic gates. gate using a NAND gate
Solution
Conversion of Boolean Expression into Circuit
Y=(A+B)+C- D+E-F)
Diagram using NAND Gates
The following are the steps to convert a given expression
into a circuit dia-gram using only NAND gates:
* Read the expression carefully and draw its corresponding
circuit diagram
* Replace every AND, OR, and NOT gate with its
equivalent NAND gate.
* Redraw the circuit.
Identify and remove double inversions (i.c¢., back-to-
back inverters, if any).
* Redraw the final circuit
GED universat Gates
Example 5.9
Universal gates are those gates that can be used for
implementing any gate such as AND, OR, and NOT. The two Y¥=A+(8-C) has been represented using AND and OR gates
important universal gates are the NAND and NOR gates. Represent it using NAND gates.
86 Computer Fundamentals and Programming in C
c ae
Solution
pp “D-
Yru Mec
A Ree (A Ry+e
Figure 5.14 Representation of a NOT
ee
gate using a NOR gate
OR Gate
The OR gate is a NOR gate followed by a NOT gate
(Figure 5.15)
>
B a >.
Figure 5.15 Representation of an OR
gate using a NOR gate
AND Gate
From the truth tables, we can observe that an AND gate
gives the output as 1 when both inputs are 1, whereas a
NOR gate outputs | only when both inputs are 0. This
Boolean Algebra and Logic Gates 87
GE) simpiFicaTion OF BOOLEAN Locke) Truth table and K-map for four variables
EXPRESSIONS USING KARNAUGH MAP A |B) C | D | Outpuy
# c@: 0) 16 0
Karnaugh map (K-map) is a tool to represent Boolean
functions of up to six variables. It is a pictorial method ooo1 1
to minimize Boolean expressions without using oo1o 0
Boolean algebra theorems and equations, thereby CK Ope we 0
making the process of minimization simpler, faster, o 1 o 0 0
and efficient
An n-variable K-map has 2n cells where cach cell
Omms !
corresponds to an n-variable truth table value. The cells 6) find HY 1 0
in a K-map are arranged in such a way that adjacent cells ol el tae o
correspond to truth rows that differ in position by only one 100 0 0
bit (logical adjacency). i) oy io 1
K-maps can be casily used to represent expressions
€]) (Oi EG Ke 0
that involve two to four variables, expressions with
five to six variables are comparatively difficult but
3 Ga Ha 0
achievable, but expressions with seven or more 45 [el FO FS 0
variables are extremely difficult (if not impossible) to 7 Del tol 1
minimize using a K-map. gt aber OB )
Consider the truth table of two variables and observe 7 el 0
the K-map for this truth table (Table 5.21). A cell of the
K-map contains a | if the output value for 4 and B in the
truth table has a 1 Rules for Minimization
Let us consider the truth tables of three (Table 5.22) and The following are the rules for minimizing an expression
four (Table 5.23) variables and observe the K-map for
using a K-map
these tables,
Rule | Form groups of cells in such a way that a group
should not include a cell with a zero value.
ceeey Truth table and K-map for three variables Rule {1 Groups may be formed either horizontally or
vertically, They cannot be formed diagonally
A|BIC Output ¥
}o 0 0 1 B
}o o 4 : \ pt
a pesos:
a oe |
|o ao S ~~ e oo
1 0; 0
(esd IEA 9 0 1T1]lo]o
ectehk Sie Se : cane |
eae :
(ca
i|
generally
2"cells. 00" 01 ll 10
Example 5.11
oo Ol tt 10
Cae
pated minnie
Example 5.12
Rule VI Groups can be = around the table. For Consider the expression Y= A’: B'-C' +A’: B'.C
example, the leftmost cell in a row can be grouped with +A’. B+ C+A’-B-C and minimize it using aK-map,
the rightmost cell. Similarly, the topmost cell in the table
may be grouped with the bottommost cell in the group.
in the group of 1s, we
see that the output is
independent of the values
of B and C. This is because
there is a 1 when B = 0
as well as when B = 1.
Similarly,
there is a1 when
C =0 as well as when C = 1. However, the output is 1 only
when A =0 or A’ = 1. Therefore,
Y= A’.
Leftmost cell
Example 5.13
Rule Vil The number of groups should be as small as
possible (provided any of the earlier-stated rules are not Consider the expression Y=A’»B'-C+A'-B-C+A+B'-C+
violated). A-8> Cand minimize itusing aK-map.
Boolean Algebra and Logic Gates 89
Consider
the expression Y=A'-B'-C'+A'-B+A-8-C'+A-C
and minimize it using K-map.
Solution
A B's
C +A B+ A+B: C +A>Ccan be expanded
as,
ABU C4+A'B(CHC)4A-B-C+A-C (B48)
AB CHA BS C+A B CHA B CHA CBAC 8.
Hence, the K-map can be drawn as
[[Group wt |
Group Il
POINTS TO REMEMBER
© Computers understand only binary numbers, in which to represent a Boolean function. This helps them to
only the digits0and 1 are used. A complex proposition reduce the number of logic gates for simplification
can be easily stated in terms of binary variables (two and minimization of digital circuits. A canonical form
variables) and binary operators (OR, AND, and NOT). can be either a sum of minterms or a product of
Boolean operators take certain inputs and produce an maxterms.
output based on a predetermined table of results . A logic gate or Boolean gate is an electronic circuit,
{also known as the truth table). A truth table lists all which acts as a basic building block of any digital
possible values of input combinations of the function system.
and the output that will be produced based on these . NAND and NOR gates are known as universal gates
input combinations, because they can be used to implement all other logic
A Venn diagram can be used to represent Boolean gates.
operations using shaded overlapping regions. Karnaugh map (K-map) is a tool to represent Boolean
¢ A variable or a complemented variable is called a functions of upto six variables. A n-variable K-map has
literal. Designers of logical circuits prefer to use a 2" cells where each cell corresponds to an n-variable
standardized form of literals called the canonical form truth table value.
90 Computer Fundamentals and Programming in C
GLOSSARY
Boolean expression A combination of Boolean variables making the process of minimization simpler, faster, and
and Boolean operators. efficient.
Boolean function A function that has one or more input Maxterm A canonical sum (or a canonical product of
variables and generates an output based on these input sums) term.
values, which may be 0 or 1. Minterm A canonical product (or a canonical sum of
K-map A tool to represent Boolean functions of up to six products) term.
variables, which minimizes Boolean expressions without Truth table A table used to describe a Boolean function
using Boolean algebra theorems and equations, thereby of n input variables.
EXERCISES
12 Explain the steps to convert a POS expression into the Implement the expressions given in Question 16 using
canonical POS form with the help of an example. NAND gates
13, Convert F(A, B, C) = (A' + B')(8' + C) to the canonical POS Implement the expressions given in Question 16 using
form. NOR gates.
14. What are logic diagrams? How are they useful? Write a short note on K-maps
15. Draw the logic diagram for the Boolean expression Y = Draw a K-map and simplify the Boolean expression given
(A-B+C -D)+(A'+Dd) by fix, y, 2) = Zm(0, 2, 3, 4, 6, 7)
16. Implement the following expressions using logic gates
(a) Y=(A-8)+(C-D)-E
(b) Y=A4(C+D)-(A-B)
Pm 4
+ Sos >
Computer Software
a”
TAKEAWAYS
© System software © Application software * Command interpreter
* BIOS © Pre-written software * Mobile operating systems
© Operating systems © Customized software * Generations of programming
© Utility software © Productivity software languages
* Translators * Microsoft Office
Computer system
Computer software can be broadly classified into two Differences between system and application
groups, namely application software and system software. software
* Application software is designed for users to solve a System software ] Application software
particular problem. It is generally what we think of when
Itis a collectionof programs —Itisa collection of programs:
we refer to a computer program. Examples of application that cnable users tointeract —_written fora specific application,
software include spreadsheets, database systems, desktop with hardware components — such as a library system,
publishing software, program development software, efficiently. inventory control system, and
games, and web browsers. Simply put, application © 08,
sofiware represents programs that allow users to do
Ktcontrols
and manages the —_It uses the services provided by
something besides merely run the hardware. hardware. the system software to interact
* On the contrary, system sofiware, provides a general with hardware components,
programming environment in which programmers can
Tt is machine-dependent. Itis machine independent,
create specific applications to suit their needs, This
The programmer must Tn most cases, the programmer
environment provides new functions that are not available
understand
the architecture ignores the architecture
ofthe
at the hardware level and performs tasks related to executing of themachine and hardware —machine and hardware details to
the application program. System software represents details to write system write application software,
programs that allow the hardware to run properly. It acts as software.
an interface between the hardware of the computer and the
Itinteractswith the hardware It interacts with the hardware
application software that users need to run on the computer. directly, indirectly through system calls
Figure 6.2 illustrates the relationship between application provided by system software.
sofiware and system software,
Writing
system software isa = Writing application programs ix
Table 6.1 lists the differences between system and complicated task. relatively easy.
application softwares. Examples include compilers Examples include Microsoft
inn Ans ee eee ee
6.2.1 System Software
S stem software is computer software designed to operate BIOS is built into the computer and is the first code run
computer hardware and to provide and maintain a platform by the computer when it is switched on. The key role of
for running application software. Some of the most widely BIOS is to load and start the operating system (OS).
used system software are discussed in this section. When the computer starts, the first function that BIOS
performs is to initialize and identify system devices such
Computer BIOS and Device Drivers as the video display card, keyboard, mouse, hard disk,
CD/DVD drive, and other hardware. In other words, the
Basic Input/Output System (BIOS) and device drivers code in the BIOS chip runs a series of tests called POST,
provide basic functionality to operate and control the which stands for power on self test, to ensure that the
hardware connected to or built into the computer. system devices are working correctly
94 Computer Fundamentals and Programming in C