Fundamentals and
Programming in
s
es
Pr
s ity
er
iv
Un
d
Reema Thareja
or
xf
Assistant Professor
Department of Computer Science
O
Published in India by
Oxford University Press
YMCA Library Building, 1 Jai Singh Road, New Delhi 110001, India
s
prior permission in writing of Oxford University Press, or as expressly permitted
es
by law, by licence, or under terms agreed with the appropriate reprographics
rights organization. Enquiries concerning reproduction outside the scope of the
above should be sent to the Rights Department, Oxford University Press, at the
Pr
address above.
ity
and you must impose this same condition on any acquirer.
ISBN-13: 978-0-19-946373-2
s
ISBN-10: 0-19-946373-5
er
Typeset in Times New Roman
by Ideal Publishing Solutions, Delhi
iv
2 10 Comprehensive Coverage
Input and Output Devices Decision Control and
Looping Statements Chapters provide a comprehensive coverage of topics
3 11 ranging from basics of computer hardware and
Computer Memory and Functions software to the basics of C programming
Processors
4 12
Number Systems and Arrays
Computer Codes
s
es
Pr
Computer fundamental_Ch01.indd 3 Computer
3/11/2016
fundamental_Ch09.indd
4:49:20 PM 165 Note
3/11/2016 4:54:46 PM
Keys such as ShiŌ, Ctrl, and Alt are called modiĮer keys
Computer fundamental_Ch02.indd 22
Programming Tip:
common programming errors and how to avoid Strings cannot be
them
Un
manipulated with
Computer fundamental_Ch04.indd 59 3/11/2016 4:34:28 PM
Computer fundamental_Ch12.indd 275 3/11/2016 4:59:48 PM
arithmeƟc or other
operators available in
C boundaries.
d
or
xf
POINTS TO REMEMBER
O
Computer fundamental_Ch02.indd 22 • A computer is an electronic machine that accepts data Points to Remember 3/11/2016 4:32:48 PM
and instrucƟons and performs computaƟons on the Summary points at the end of each chapter help
data based on those instrucƟons.
• Computers are used in all interacƟve devices, such as readers to revise all the important concepts explained
cellular telephones, GPS units, portable organizers, in the chapter
ATMs, and gas pumps.
Includes a list of key terms along with their definitions instrucƟons into the computer
OpƟcal character recogniƟon The process of converƟng
from the computer to the user
PoinƟng device A device that enables the users to easily
printed materials into text or word processing Įles that control the movement of the pointer to select items on
for a quick recapitulation of important terms learned can be easily edited and stored a display screen, to select commands from the command
OpƟcal device A device that uses light as a source of input menu, to draw graphics, etc
in all chapters for detecƟng or recognizing diīerent objects Printer A device that takes the text and graphics informaƟon
obtained from a computer and prints it on paper
OpƟcal mark recogniƟon The process of electronically
s
2. Write a program to print Hello World, using pointers.
es
#include <stdio.h>
int main()
Pr
Programming Examples {
char *ch = "Hello World";
About 250 C programs are included, which printf("%s", ch);
demonstrate the applicability of the concepts learned
s ity }
return ɧ;
Output
er
Hello World
iv
Un
APPENDIX
F
d
Answers to Objective
or
EXERCISES
Exercises Fill in the Blanks
ϭ͘ ǁĂƐĚĞǀĞůŽƉĞĚďLJͺͺͺͺͺͺͺͺ͘
;ĐͿ >ŽŐŝĐĂůKZ ;ĐͿ ŝƚǁŝƐĞEKd
ϱ͘ tŚŝĐŚŽƉĞƌĂƚŽƌŚĂƐƚŚĞůŽǁĞƐƚƉƌĞĐĞĚĞŶĐĞ͍
Ϯ͘ ͺͺͺͺͺͺͺͺŝƐĂŐƌŽƵƉŽĨƐƚĂƚĞŵĞŶƚƐƚŚĂƚĂƌĞĞdžĞĐƵƚĞĚ ;ĂͿ ƐŝnjĞŽĨ ;ďͿ ƵŶĂƌLJ
Includes plenty of program code-related programs ƚŽŐĞƚŚĞƌ͘ ;ĐͿ ĂƐƐŝŐŶŵĞŶƚ ;ĚͿ ĐŽŵŵĂ
ϯ͘ džĞĐƵƟŽŶŽĨƚŚĞƉƌŽŐƌĂŵďĞŐŝŶƐĂƚͺͺͺͺͺͺͺͺ͘ ϲ͘ ^ŚŽƌƚŝŶƚĞŐĞƌŚĂƐǁŚŝĐŚĐŽŶǀĞƌƐŝŽŶĐŚĂƌĂĐƚĞƌĂƐƐ
at the end of relevant chapters, which require the ϰ͘ /ŶŵĞŵŽƌLJĐŚĂƌĂĐƚĞƌƐĂƌĞƐƚŽƌĞĚĂƐͺͺͺͺͺͺͺͺ͘ ǁŝƚŚŝƚ
ϱ͘ dŚĞƐƚĂƚĞŵĞŶƚɧ͖ƌĞƚƵƌŶƐϬƚŽƚŚĞͺͺͺͺͺͺͺͺ͘ ;ĂͿ йĐ ;ďͿ йĚ
readers to find the output of a given code, the ϲ͘ ͺͺͺͺͺͺͺͺĮŶĚƐƚŚĞƌĞŵĂŝŶĚĞƌŽĨĂŶŝŶƚĞŐĞƌĚŝǀŝƐŝŽŶ͘
;ĐͿ йŚĚ ;ĚͿ йĨ
ϳ͘ ͺͺͺͺͺͺͺͺŽƉĞƌĂƚŽƌƌĞǀĞƌƐĞƐƚŚĞǀĂůƵĞŽĨƚŚĞĞdžƉƌĞƐƐŝŽŶ͘
ϳ͘ tŚŝĐŚŽĨƚŚĞĨŽůůŽǁŝŶŐŝƐŶŽƚĂĐŚĂƌĂĐƚĞƌĐŽŶƐƚĂŶ
functionality of a given loop, or errors in a given ϴ͘ sizeofŝƐĂͺͺͺͺͺͺͺͺŽƉĞƌĂƚŽƌƵƐĞĚƚŽĐĂůĐƵůĂƚĞƚŚĞƐŝnjĞ
;ĂͿ ͚͛ ;ďͿ ͟͞
ŽĨĚĂƚĂƚLJƉĞƐ͘
program code ϵ͘ ͺͺͺͺͺͺͺͺŝƐĂůƐŽŬŶŽǁŶĂƐĨŽƌĐĞĚĐŽŶǀĞƌƐŝŽŶ͘ ;ĐͿ ͚͚ ;ĚͿ ͚*͛
ϴ͘ tŚŝĐŚŽĨƚŚĞĨŽůůŽǁŝŶŐŝƐŶŽƚĂŇŽĂƟŶŐƉŽŝŶƚĐŽŶ
ϭϬ͘ dŚĞscanf()ĨƵŶĐƟŽŶƌĞƚƵƌŶƐͺͺͺͺͺͺͺͺ͘
ϭϭ͘ ͺͺͺͺͺͺͺͺĨƵŶĐƟŽŶƉƌŝŶƚƐĚĂƚĂŽŶƚŚĞŵŽŶŝƚŽƌ͘ ;ĂͿ ϮϬ ;ďͿ Ͳϰ͘ϱ
; Ϳ ͚ ͛ ;ĚͿ
s
website, C tops the list followed by C++ and Java.
es
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,
Pr
network programming, parallel programming, other programming languages, and new and emerging computing
paradigms such as grid-computing and cloud computing.
PEDAGOGICAL FEATURES
Un
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.
xf
Complete program codes Contains plenty of program codes that are thoroughly tested and compiled to support the
text
O
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.
Chapter 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 In order to make the text more coherent, this chapter has been restructured to focus on the program designing
s
tools that aid in the development of efficient programs. The section on programming languages has been shifted to
es
chapter 6.
Chapter 9 This chapter includes an annexure, which shows the steps to compile and execute C programs on both Unix/
Pr
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.
ity
Chapter 14 It includes a program to illustrate the dangling pointer problem.
s
Chapter 15 It presents three different ways to find the size of a structure. All these different methods have been
er
exemplified through program codes.
iv
The book is divided into two parts spanning 18 chapters and five appendices.
Chapter 1, Introduction to Computers, provides an introduction to computers. The chapter explains the generations,
or
Chapter 3, Computer Memory and Processors, explains the significance of memory hierarchy and discusses the different
types of primary and secondary memory that are widely used to store data. It also discusses the basic processor architecture
O
s
Chapter 13, Strings, discusses the concept of strings, which are better known as character arrays. The chapter not only
es
focuses on reading and writing strings but also explains various operations that can be used to manipulate them.
Chapter 14, Pointers, presents a detailed overview of pointers, pointer variables, and pointer arithmetic. The chapter also
Pr
relates the use of pointers with arrays, strings, and functions. This helps readers to understand how pointers can be used
to write better and efficient programs.
ity
Annexure 3 explains the process of deciphering pointer declarations.
Case Study 3 includes a program which demonstrates how pointers can be used to access and manipulate strings.
s
Chapter 15, Structure, Union, and Enumerated Data Type, introduces user-defined data types— structures and unions.
er
It includes the use of structures and unions with pointers, arrays, and functions so that the inter-connectivity between the
programming techniques can be well understood.
iv
Chapter 16, Files, discusses how data can be stored in files. The chapter deals with opening, processing, and closing of
files through a C program. These files are handled in text mode as well as binary mode for better clarity of the concepts.
Chapter 17, Preprocessor Directives, deals with preprocessor directives. It includes small program codes that illustrate
d
Chapter 18, Introduction to Data Structures, provides an introduction to different data structures such as linked lists,
stacks, queues, trees, and graphs.
xf
Appendix A, Bitwise Operations, discusses bit-level programming and some of the bitwise operators.
Appendix B, ANSI C Library Functions, lists some of the ANSI C library functions and their descriptions.
O
Appendix C, Advanced Type Qualifiers and Inline Functions in C, introduces some advanced type qualifiers as well as
inline functions.
Appendix D, Interview Questions with Solutions, includes about 100 frequently asked interview questions along with
their solutions.
Appendix E, Linux: A Short Guide discusses the basics of Linux kernel and shell and describes the most commonly used
Linux commands.
Appendix F, Answers to Objective Questions, provides answers to objective questions.
ACKNOWLEDGEMENTS
I would like to gratefully acknowledge the feedback and suggestions provided by various faculty members for the
improvement of the book. I am obliged to the editorial team at Oxford University Press India for all their 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 [email protected].
Reema Thareja
s
es
Computer Fundamentals and Programming in C is aimed at serving as a textbook for undergraduate level courses in
computer science and engineering and postgraduate level courses of computer applications. The objective of this book
Pr
is to introduce the students to the fundamentals of computers and the concepts of the C programming language and
enable them to apply these concepts for solving real-world problems. The book has been designed keeping in mind the
requirements of a basic first-level course on computer fundamentals and programming, which is offered as a common
ity
subject in all engineering disciplines. It comprehensively covers the fundamental concepts of computers, including topics
such as introduction to computers, number system, input/output devices, computer memory, computer software, the
s
Internet, and introduction to algorithms and programming languages. Programming is a skill best developed by rigorous
er
practice. Keeping this in mind, the book provides a number of examples and exercises that would help the reader learn
how to design efficient, workable programs. Various programming examples that have been thoroughly implemented and
iv
ACKNOWLEDGEMENTS
or
The writing of this textbook was a mammoth task for which a lot of help was required from many people. Fortunately, I
have had the fine support of my family, friends, and fellow members of the teaching staff at the Institute of Information
xf
Pallav, and sisters Kimi and Rashi who were a source of inspiration and divine blessings for me. I 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, I 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 I 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
s
4 Number Systems and Computer Codes 59
es
5 Boolean Algebra and Logic Gates 76
Pr
6 Computer Software 92
7 Computer Networks and the Internet 124
8 Designing Efficient Programs
s ity 149
er
PART II: PROGRAMMING IN C 163
9 Introduction to C 165
iv
11 Functions 248
12 Arrays 275
d
13 Strings 317
or
14 Pointers 347
xf
s
1.4 History of Computers 5 3.13 USB Flash Drives 48
es
1.5 Classification of Computers 9 3.14 Memory Cards 49
1.5.1 Supercomputers 9 3.15 Mass Storage Devices 50
Pr
1.5.2 Mainframe Computers 9 3.15.1 Disk Array 50
1.5.3 Minicomputers 9 3.15.2 Automated Tape Library 50
1.5.4 Microcomputers 10 3.15.3 CD-ROM Jukebox 50
1.6 Applications of Computers 11
1.7 Basic Organization of a Computer 15
s ity 3.16 Basic Processor Architecture 51
3.16.1 Execution Unit 51
1.8 Lab Session—Inside the Computer 16 3.16.2 Registers 51
er
1.9 Motherboard 17 3.16.3 Bus Interface Unit 52
1.9.1 Characteristics of a Motherboard 17 3.16.4 Instruction Set 52
iv
Decimal Form 61
3 Computer Memory and Processors 39
4.3.2 Converting a Decimal Number into
3.1 Introduction 39
Binary Form 61
3.2 Sequential and Random Access 39
4.3.3 Adding Two Binary Numbers 61
3.3 Memory Hierarchy 39
4.3.4 Subtracting Two Binary Numbers 62
3.4 Processor Registers 40
4.3.5 Subtracting Two Binary Numbers Using
3.5 Cache Memory 40
Two’s Complement 62
3.6 Primary Memory 40
4.3.6 Multiplying Two Binary Numbers 63
3.6.1 Random Access Memory (RAM) 41
4.3.7 Dividing Two Binary Numbers 63
3.6.2 Read-only Memory (ROM) 41
4.4 Octal Number System 63
3.6.3 Finding Required Data from Main
4.4.1 Converting an Octal Number into
Memory 42
Decimal Form 63
3.7 Secondary Storage Devices 42
4.4.2 Converting a Decimal Number into
3.7.1 Offline Storage 42
Octal Form 64
3.8 Magnetic Tapes 43
4.4.3 Converting an Octal Number into
3.9 Floppy Disks 43
Binary Form 64
3.10 Hard Disks 44
4.4.4 Converting a Binary Number into Octal
3.11 External Hard Disks 46
Form 64
3.12 Optical Drives 46
s
4.5.8 Subtracting Two Hexadecimal
6.7 Database Management Software 109
es
Numbers 68
6.8 Operating Systems 110
4.6 Working with Fractions 68
6.8.1 Types of Operating Systems 110
Pr
4.7 Signed Number Representation in Binary
6.8.2 Command Interpretation 111
Form 69
6.9 Popular Operating Systems 112
4.7.1 Sign-and-magnitude 70
4.8
4.7.2 One’s Complement 70
4.7.3 Two’s Complement 70
BCD Code 70
s ity 6.9.1 Microsoft DOS 112
6.9.2 Windows 113
6.9.3 UNIX 115
6.9.4 Linux 116
er
4.9 Other Codes 71
6.10 Mobile Operating Systems 116
4.9.1 ASCII Code 71
6.11 Programming Languages 117
iv
4.9.6 Unicode 73
6.12.3 Third Generation: High-level
or
s
7.7.5 Hybrid Topology 131
8.1.3 Structured Programming 150
es
7.8 Wireless Networks 132
8.1.4 Object-oriented Programming
7.9 Data Transmission Mode 133
(OOP) 151
Pr
7.9.1 Simplex, Half-duplex, and Full-duplex
8.2 Example of a Structured Program 151
Connections 133
8.3 Design and Implementation of Efficient
7.9.2 Serial and Parallel Transmissions 134
7.9.3 Synchronous and Asynchronous Data
Transmission Modes 135
7.10 Open System Interconnection
s ity Programs 152
8.4 Program Design Tools: Algorithms, Flowcharts,
Pseudocodes 153
8.4.1 Algorithms 153
er
Model 136
8.4.2 Control Structures Used in
7.11 Transmission Control Protocol/Internet
Algorithms 153
iv
s
10.2 Conditional Branching Statements 205 12.2 Declaration of Arrays 275
es
10.2.1 If Statement 205 Points to Remember 276
10.2.2 if–else Statement 207 12.3 Accessing the Elements of an Array 276
Pr
10.2.3 if–else–if Statement 209 12.3.1 Calculating the Address of Array
10.2.4 switch case 212 Elements 277
10.3 Iterative Statements 216
10.3.1 while Loop 216
10.3.2 do-while Loop 218
s ity 12.3.2 Calculating the Length of an
Array 277
12.4 Storing Values in Arrays 278
10.3.3 for Loop 221 12.4.1 Initializing Arrays during
er
10.4 Nested Loops 224 Declaration 278
10.5 Break and Continue Statements 232 12.4.2 Inputting Values from the
iv
11 Functions 248
12.5.2 Inserting an Element in an Array 283
11.1 Introduction 248
or
Array 289
11.5 Function Call 251
12.6 Passing Arrays to Functions 292
11.5.1 Points to Remember While Calling
12.7 Two-Dimensional Arrays 295
Functions 251
12.7.1 Declaring Two-dimensional
11.6 Return Statement 252
Arrays 295
11.6.1 Using Variable Number of
12.7.2 Initializing Two-dimensional
Arguments 253
Arrays 296
11.7 Passing Parameters to Functions 253
12.7.3 Accessing the Elements of
11.7.1 Call by Value 253
Two-dimensional Arrays 297
11.7.2 Call by Reference 254
12.8 Operations on Two-Dimensional Arrays 300
11.8 Scope of Variables 257 12.9 Passing Two-Dimensional Arrays to
11.8.1 Block Scope 257 Functions 302
11.8.2 Function Scope 258 12.9.1 Passing a Row 303
11.8.3 Program Scope 258 12.9.2 Passing an Entire 2D Array 303
11.8.4 File Scope 259 12.10 Multidimensional Arrays 305
11.9 Storage Classes 259 12.11 Sparse Matrices 306
11.9.1 auto Storage Class 259 12.11.1 Array Representation of Sparse
11.9.2 register Storage Class 260 Matrices 307
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 317
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.1.3 Summary of Functions Used to Read
14.15.1 Initializing a Function Pointer 368
and Write Characters 320
14.15.2 Calling a Function Using a Function
13.2 Suppressing Input 321
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 Pointer as 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
s
14.20 Dynamic Memory Allocation 371
Lower Case 324
es
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
Pr
14.20.3 Releasing the Used Space 372
13.4.5 Appending a String to Another
14.20.4 To Alter the Size of Allocated
String 325
Memory 373
13.4.6 Comparing Two Strings 326
13.4.7 Reversing a String 325
13.4.8 Extracting a Substring from
ity
14.21 Drawbacks of Pointers 374
Annexure 3 382
Case Study 3: Chapters 13 and 14 384
s
Left 327
er
13.4.9 Extracting a Substring from Right of 15 Structure, Union, and Enumerated
the String 328 Data Type 386
iv
s
17.8.6 #endif 456
16.2.3 Closing a File Using fclose() 418
es
17.9 defined Operator 456
16.3 Reading Data From Files 418
17.10 #error 456
16.3.1 fscanf () 418
Pr
17.11 Predefined Macro Names 457
16.3.2 fgets() 419
16.3.3 fgetc() 420 18 Introduction to Data Structures 460
16.3.4 fread() 420
16.4 Writing Data to Files 421
16.4.1 fprintf() 421
s ity18.1 Introduction 460
18.2 Classification of Data Structures 460
18.2.1 Primitive and Non-primitive Data
16.4.2 fputs () 422 Structures 460
er
16.4.3 fputc () 423 18.2.2 Linear and Non-linear Structures 460
16.4.4 fwrite () 423 18.3 Arrays 461
iv
16.8 Functions for Selecting a Record 18.4.4 Deleting a Node from a Linked
or
TAKEAWAYS
• Characteristics of computers • Generations of computers • Basic organization of
• Digital computers • Types of computers a computer
• Stored program concept • Applications of computers
s
es
and say that the age of the student is 23 years, then the
1.1 COMPUTER
Pr
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
the required mathematical and logical operations at high
speed, and output the result.
s ity
need televisions, telephones, or other electronic devices at
home. Computers are basically meant to solve problems
quickly and accurately. The important characteristics
We all have seen computers in our homes, schools, and
er
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 daily lives. For some of us, it is hard to
iv
Economical
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
A
ut
om
IQ
were too expensive to be used for commercial applications.
d
at
o
N
io
the size of computers became smaller and their energy Diligence Computers
memory
requirements reduced immensely. This opened the way for
O
cc
til
ur
Speed
a
er
cy
V
1.2 CHARACTERISTICS OF COMPUTERS Speed Computers can perform millions of operations per
second, which means that data that may otherwise take
We have seen that a computer is an electronic device that many hours to process is output as information in the
performs a function based on a given set of instructions blink of an eye. The speed of computers is usually given
known as a program. A computer accepts data, processes in nanoseconds and picoseconds, where 1 nanosecond =
it, and produces information. Here, data refers to some 1 × 10−9 seconds and 1 picosecond = 1 × 10−12 seconds.
raw fact or figure, and information implies the processed Accuracy A computer is a very fast, reliable, and robust
data. For example, if 12-12-92 is the date of birth of a electronic device. It always gives accurate results,
student, then it is data (a raw fact/figure). However, when provided the correct data and set of instructions are input
we process this data (subtract it from the present-date) to it. Hence, in the event of an error, it is the user who has
fed 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 to an 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- 1.3 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
s
duration, and is executed with the same accuracy. memory.
es
Versatile Versatility is the quality of being flexible. Today, • Instructions are stored in the computer’s memory for
computers are used in our daily life in different fields. For execution.
Pr
example, they are used as personal computers (PCs) for • Instructions are stored in binary form (using binary
home use, for business-oriented tasks, weather forecasting, numbers—only 0s and 1s).
• Processing starts with the first instruction in the program,
space exploration, teaching, railways, banking, medicine,
and so on, indicating that computers can perform different
tasks simultaneously. On the PC that you use at home,
s ity
which is copied into a control unit circuit. The control
unit executes the instructions.
you may play a game, compose and send e-mails, listen • Instructions written by the users are performed
er
to music, etc. Therefore, computers are versatile devices sequentially until there is a break in the current flow.
as they can perform multiple tasks of different nature at • Input/Output and processing operations are performed
iv
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,
Note
d
external or secondary memory. While the internal memory computer architecture wherein the computer executes
of computers is very expensive and limited in size, the the instructions that are stored in its memory.
xf
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
No IQ Although the trend today is to make computers instructions.
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
Main
Processor Data Bus - carries data and instructions Memory
(a)
Instruction Data
Instructions Processor Read/Write Data
memory memory
s
es
(b)
Figure 1.2 Von Neumann architecture (a) Shared memory for instructions and data (b) Separate
Pr
memories for instructions and data
becomes faster. The system completed the task in three years saving the
or
Early computers were designed not for entertainment but of computing anything that is computable. 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 smartphones have much more computing power
physicist, and his graduate student, Clifford Berry, at Iowa
than that was available in those early computers.
State College designed Atanasoff–Berry computer (ABC)
In this section, we will read about history of computers
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 × 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 as that of a 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.
1947: 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
invented integrated circuit, which is commonly known as 1996: Sergey Brin and Larry Page developed the Google
the computer chip. search engine at Stanford University.
1964: Douglas Engelbart developed a prototype of the 1999: The term Wi-Fi was introduced when users started
modern computer, with a mouse and a graphical user connecting to the Internet without wires.
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.
s
multi-tasking, among other benefits. To stay competitive,
es
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
Pr
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
1970: DRAM chip was introduced by Intel.
1971: Alan Shugart with his team in IBM invented
s ity
Facebook, a social networking site, was launched.
2005: YouTube, a video sharing service, was launched. In
the same year, Google acquired Android, a Linux-based
er
the floppy disk which allowed data to be shared among
mobile phone operating system.
computers.
2006: Apple introduced MacBook Pro, its first Intel-
iv
and other hardware. 2007: Apple released iPhone, which brought many
1974–1977: Personal computers started becoming computer functions in the smartphone.
popular. 2009: Microsoft launched Windows 7 in which users
d
1975: Paul Allen and Bill Gates started writing software for could pin applications to the taskbar.
or
the Altair 8800 using the new BASIC language. On April 4, 2010: Apple launched iPad, which revived the tablet
they both formed their own software company, Microsoft.
xf
computer segment.
1976: Steve Jobs and Steve Wozniak started Apple 2011: Google introduced Chromebook, a laptop that runs
O
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 II 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 Technology Programming was done in machine
system. or assembly language.
Used for Scientific applications • They consumed 1/10th the power consumed by first
generation computers
Examples ENIAC, EDVAC, EDSAC, UNIVAC I, 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
• Computers were too bulky and required a complete still required air-conditioned rooms
room for storage • Costly
• 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.
Therefore, these computers were prone to frequent
hardware failures
s
es
Figure 1.4 Transistors
Pr
Source: yurazaga/Shutterstock
• 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
s
es
Figure 1.5 Integrated circuits
Figure 1.6 VLSI chip
Source: cooldesign/FreeDigitalPhotos.net
Pr
Fifth Generation (1989–Present)
Fourth Generation (1975–1989)
Hardware Technology Fifth generation computers are
Hardware Technology Fourth generation computers
were manufactured using ICs with LSI (Large Scale
Integrated) and later with VLSI technology (Very Large
s ity
manufactured using ICs with ULSI (Ultra Large Scale
Integrated) technology. The use of Internet became
widespread and very powerful mainframes, desktops,
er
Scale Integration). Microcomputers came into existence. portable laptops, and smartphones are being used commonly.
Use of personal computers became widespread. High Supercomputers use parallel processing techniques.
iv
• High-end features available on mainframe computers units, etc. Some examples of supercomputers are CRAY-1,
in the fourth generation are now available on the CRAY-2, Control Data CYBER 205, and ETA A-10.
microprocessors
• 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 S/390 mainframe can support 50,000
users at the same time. Users can access mainframes by
either 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
s
(or mouse). They do not have their own CPU and memory
es
Figure 1.7 ULSI chip and use the mainframe system’s CPU and storage devices.
Pr
Intelligent Terminals
1.5 CLASSIFICATION OF COMPUTERS
In contrast to dumb terminals, intelligent terminals have
Computers can be broadly classified into four categories
based on their speed, amount of data that they can process,
s ity
their own processor and thus can perform some processing
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
er
follows: as intelligent terminals to facilitate data access and other
• Supercomputers services from the mainframe system.
iv
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
Minicomputers are widely used in business, education, easily be carried from one place to another. They may also
hospitals, government organizations, etc. 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
simultaneously. 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.
s
Microcomputers, commonly known as PCs, are very small Workstations
es
and cheap. The first microcomputer was designed by IBM
in 1981 and was named IBM-PC. Later on, many computer Workstations are single-user computers that have the same
hardware companies copied this design and termed their features as PCs, but their processing speed matches that
Pr
microcomputers as PC-compatible, which refers to any of a minicomputer or mainframe computer. Workstation
PC that is based on the original IBM PC design. computers have advanced processors, more RAM and
Another type of popular PC is designed by Apple. PCs
designed by IBM and other PC-compatible computers
have a different architecture from that of Apple computers.
s ity
storage capacity than PCs. Therefore, they are more
expensive and powerful than a normal desktop computer.
Although workstation computers are widely used as
Moreover, PCs and PC-compatible computers commonly powerful single-user computers by scientists, engineers,
er
use the Windows operating system, while Apple computers architects, and graphic designers, they can also be used as
use the Macintosh operating system (MacOS). PCs can be servers in a networked environment.
iv
Network Computers
Desktop PCs
Network computers have less processing power,
A desktop PC is the most popular model of PCs. The memory, and storage than a desktop computer. These are
d
system unit of the desktop PC can be placed flat on a desk specially designed to be used as terminals in a networked
or
or table. It is widely used in homes and offices. environment. For example, some network computers are
specifically designed to access data stored on a network
xf
Laptops (Figure 1.9) are small microcomputers that can and merely rely on the network’s server for data storage and
easily fit inside a briefcase. They are very handy and can processing tasks. The concept of network computers had
become popular in the mid-1990s when several variations
of computers such as Windows terminals, NetPCs, and
diskless workstations were widely used.
Network computers that are specifically designed to access
only the Internet or intranet are often known as Internet PCs
or Internet boxes. Some network computers used in homes do
not even have a monitor. Such computers may be connected
to a television, which serves as the output device. The most
common example of a home-based network computer is
Web TV, which enables the user to connect a television to the
Internet. The Web TV is equipped with a special set-top box
that is used to connect to the Internet. The set-top box also
provides controls to enable the user to navigate the Internet,
send and receive e-mails, and to perform other tasks on the
network while watching television. The other reason for the
Figure 1.9 Laptop popularity of network computers is that they are cheaper to
Source: You can more/Shutterstock purchase and maintain than PCs.
Smartphones These days, cellular phones are web-enabled Tablets may replace laptops if users don’t have to
telephones. Such phones are also known as smartphones perform heavy processing tasks and do not require a CD
because, in addition to basic phone capabilities, they also or DVD player
s
facilitate the users to access the Internet and send e-mails,
es
edit Word documents, generate an Excel sheet, create a
presentation, and lots more.
Pr
Smartphones run an advanced mobile operating
system that enables it to run various applications. The
four major mobile operating systems are iOS, Android,
BlackBerryOS, and Windows Mobile. Smartphones also
have a CPU, more storage space, more memory, and a
s ity
larger screen than a regular cell phone.
er
In a nutshell, smartphone refers to a multi-functional
mobile phone handset that packs in varied functionalities
iv
processing power, battery life, and storage capability. only in the fields of mathematics and science. In fact, the
Some operating systems that are used in tablets are first effective utilization of computers was for decoding
Android Jellybean (an open-source operating system messages in military applications. Later on, computers
built by Google), Windows 8, and iOS (developed by were used in real-time control systems, like for landing on
Apple). Each operating system has its own advantages the moon. However, with the advancement of technology,
and disadvantages and a proprietary app store, from which the cost of computers and their maintenance declined.
users can download applications, extending the tablet’s This opened the way for computers to be extensively used
functionality. These apps range from games to specialized in the business and commercial sector for information
word processors and even instruments. processing. Today, computers are widely used in fields
While users can easily type directly on the surface of a such as engineering, health care, banking, education,
tablet, some users prefer a wireless or bluetooth-connected etc. Let us discuss how computers are being effectively
keyboard. These days, tablets also offer an optional utilized to perform important tasks.
docking station with keyboards that transforms the tablet
into a full-featured netbook. Word processing Word processing software enables users
to read and write documents. Users can also add images,
Uses The following are the uses of Tablet PCs: tables, and graphs for illustrating a concept. The software
• View presentations automatically corrects spelling mistakes and includes
• Videoconferencing copy–paste features (which is very useful where the same
• Reading e-books, e-newspaper text has to be repeated several times).
Internet The Internet 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 to 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 meetings with
as catalogues, 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.
s
their products to their dealers.
es
Desktop publishing Desktop publishing software enables
us to create page layouts for entire books. Consumer-to-consumer or C2C This type of electronic
commerce enables customers to carry business transactions
Pr
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.
e-Business
s ity
another customer.
Electronic banking Electronic banking, also known as
cyberbanking or online banking, supports various banking
er
e-Business or electronic business is the process of activities conducted from home, a business, or on the road
conducting business via the Internet. This may include instead of a physical bank location.
iv
messages. Videoconferencing, which is an advanced form drug discovery and development. The need for analysis has
of teleconferencing, provides a complete simulation of become even more important with enormous amount of
xf
a normal meeting environment in which all concerned genomic information available publicly from the Human
parties can see, hear, and present material, just as if they Genome Project.
O
were in the same room. These meetings not only speed up Bioinformatics is an interdisciplinary field of molecular
business process but also save the cost of travel and cost of biology, computer science, statistics, and mathematics. It
the time wasted during travel. involves analyses of genomic information to understand
human diseases and thus discover new drugs to treat those
Note diseases.
We know that DNA is made up of smaller pieces of
Both the terms—e-Commerce and e-Business—are often molecules and the sequence of molecules along a string
used interchangeably. of DNA contains all information about an organism. This
information can be used to grow new organisms. For
Companies today use e-commerce applications for example, scientists are using this information to grow
marketing, transaction, processing, and product and better variety of crops, to generate a genome that will
customer services processing. For example, the website enable cows to yield more milk, so and so forth.
of a company can perform activities such as interactive Therefore, bioinformatics helps scientists to store the
marketing, ordering, payment, and customer support DNA information in huge databases, retrieve it as and
process. when required, and analyse it to grow and develop new
e-commerce used to perform transactions between organisms.
business partners or customers has several applications Scientists also use bioinformatics to identify diseases
such as home banking, electronic shopping, buying and discover drugs for them. This is done by writing
special programs that compare the sequence of molecules Doctors sitting in hospitals can monitor their patients
in DNA of a healthy person with that of the 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 a 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.
s
Earlier, patient records were kept on paper, with separate Remote sensing is the science of taking measurements
es
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
Pr
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.
Now, the entire medical history of patients is easily
s ity
contact with it. Remote sensing is a sub-field of geography,
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:
er
can be easily shared between different doctors (in same
• Monitoring deforestation in areas like the Amazon
or different healthcare organizations) who are treating
Basin
iv
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
d
computer to control and move surgical instruments in • Determining the prospect for minerals
or
the patient’s body for a variety of surgical procedures. In • Locating 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
xf
surgical tool with an attached camera is placed inside the and precise timings of seismograms collected from
patient’s body. This reduces the risk of complications from different locations
O
Weather 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 Note
are used by utility companies to estimate demand over Edutainment is the combination of education with
coming days. 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 find 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
s
atmosphere. briefs in time for filling cases.
es
Maritime meteorology Maritime meteorology is the Retail Business
Pr
study of air and wave forecasts for ships operating at sea.
Computers are used in retail shops to enter orders, calculate
Multimedia and Animation costs, and print receipts. They are also used to keep an
chemicals through the air and ground, and the respiratory available that help a sportsperson to practice his or her
system to name a few. Animation is an easy and effective skills as well as identify flaws in the technique.
way to show complex interactions or events. Thus, it is an
excellent tool for educating an audience. Travel and Tourism
A dynamic multimedia presentation (created using Computers are used to prepare tickets, monitor the train’s
tools like MS PowerPoint) can make the message not or airplane’s route, and guide the plane to a safe landing.
only easily understood but also effective. Multimedia They are also used to research about hotels in an area,
presentation helps corporate people to share information reserve rooms, or to rent a car.
or their ideas and graphically present information in a
more understandable and persuasive manner. Multimedia Simulation
presentations can be recorded and played or displayed
dynamically depending on user’s inputs. Multimedia and Supercomputers that can process enormous amount of
animation is used to create computer games. A laser show data are widely used in simulation tests. Simulation of
is also an example of a multimedia application. automobile crashes or airplane emergency landings is done
Multimedia and animation is used to add special effects to identify potential weaknesses in designs without risking
in movies. In education, multimedia is used to prepare human lives. Supercomputers also enable engineers to
training courses. Students find learning complex computer design aircraft models and simulate the effects that winds
algorithms and data structures by reading only a textual and other environmental forces have on those designs.
Astronauts are trained using computer-simulated problems humans cannot work. For example, in high temperature,
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 a
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 earth 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.
Expert Systems
s
Education
es
A computer is a powerful teaching aid and can act as Expert systems are used to automate the decision-making
another teacher in the classroom. Teachers use computers to process in a specific area, such as analysing the credit
Pr
develop instructional material. Teachers may use pictures, histories for loan approval and diagnosing a patient’s
graphs, and graphical presentations to easily illustrate condition for prescribing an appropriate treatment. Expert
an otherwise difficult concept. Moreover, teachers at all
levels can use computers to administer assignments and
keep track of grades. Students can also give exams online
s ity
systems analyse the available data in depth to recommend
a course of action. A medical expert system might provide
the most likely diagnosis of patient’s condition.
and get instant results. To create an expert system, an extensive amount of
er
human expertise in a specific area is collected and stored
Industry and Engineering in a database, also known as a knowledge base. A software
iv
Computerized process control (with or without human online, find your batchmates, send and receive greetings
or
Data and
instructions Input Storage Output Results
CPU
Control unit
Arithmetic and
Flow of data and instructions
logical unit
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.
s
trackball. Note that computers understand binary language, The output devices, therefore, convert the results available
es
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.
Pr
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
be used for processing. The computer storage space not
s ity
controls all the components of the computer system. It
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
er
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.
iv
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
Un
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 is used to store the data and and monitors the operations of other units (such as input,
parts of programs, the intermediate results of processing,
d
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)
xf
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
O
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. Note
It is cheaper, non-volatile, and used to permanently store
data and programs of those jobs that are not being currently ALU, CU, and CPU are the key functional units of a
executed by the CPU. Secondary memory supplements computer system.
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. 1.8 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 of this chapter, the instructor must show the parts
as monitor, and printer. Since the computer accepts data of the computer to the students, as illustrated in Figure 1.12.
Optional gigabit
PS/2 mouse Parallel Ethernet ethernet SGI image Sync
PS/2 Keyboard USB Serial 1 Serial 2 Graphics Secondary ethernet Sound card
s
es
The following are some of the major parts of the These days, many computers come with a built-in sound
Pr
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
the computer system. The faster the CPU, the quicker
programs can process the instructions.
s ity
Modem A modem (modulator–demodulator) is a device
that enables the computer to use a telephone line to
communicate and connect to the Internet.
er
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 either to other computers or to the Internet (in
iv
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).
Un
Hard disk drive (HDD) The HDD of the computer is Cables There are multiple wires inside the computer
or
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
xf
Input–Output connectors
Audio chip
Processor support
Chipset (1)
s
Chipset (2)
es
Processor power supply connector
Pr
RAM connectors
BIOS
CMOS
battery
s ity
er
iv
Un
Jumpers Disk drive and floppy drive connectors Case fan power supply
connector
Figure 1.13 Computer’s motherboard
d
or
Form factor Form factor refers to the motherboard’s of the computer (such as the processor and memory). In
geometry, dimensions, arrangement, and electrical order to enhance the computer’s upgradeability, one must
xf
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,
O
Parallel Line in
Mouse
Line out
Keyboard Microphone
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
s
that you need to change the battery.
es
compared to mass storage devices such as hard drives.
BIOS The basic input/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
Pr
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
configuration.
To configure the BIOS, the user can use an interface
s ity
plug into motherboard connectors.
Expansion slots Expansion slots are compartments into
which expansion cards can be inserted. Such cards render
known as BIOS setup, which can be accessed when the
er
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. F1 and F2 keys can also be used.
iv
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
d
processor can perform 800 million operations per second. • A serial port to connect some old peripherals
• A parallel port to connect old printers
or
insert the processor, so that none of its pins are bent (it has • RJ45 connector (also known as LAN or Ethernet port)
to connect the computer to a network. It corresponds to
O
POINTS TO REMEMBER
• A computer is an electronic machine that accepts data • Modern-day computers are based on the principle of
and instructions and performs computations on the the stored program concept, which was introduced by
data based on those instructions. Sir John von Neumann in the late 1940s.
• Computers are used in all interactive devices, such as • The speed of the computer is usually given in
cellular telephones, GPS units, portable organizers, nanoseconds and picoseconds.
ATMs, and gas pumps.
• The term computer generation refers to the different computers, with thousands of integrated circuits built
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 of computers. the parent board, is the primary component of a
• The microprocessor started the fourth generation of computer.
s
GLOSSARY
es
Computer A computer is an electronic machine that takes computers all over the world.
Pr
instructions and performs computations based on those Memory shadow The process of copying data from CMOS
instructions. into RAM.
Expert systems Expert systems are custom-written computer
programs that are ‘expert’ in a particular problem area, and
embody a human expert’s knowledge, experience, and
s ity
Program A set of instructions executed by the computer.
Robotics Computers programmed to look, listen, and
react to other sensory stimuli.
problem-solving strategies. They are being used in many
er
Semiconductor devices Semiconductor devices are
areas such as medicine, chemistry, geology, meteorology, and
electronic components that make use of the electronic
computer systems.
iv
offers graphical icons and visual indicators to display the Storage The process of saving data and instructions
information and actions available to a user. The actions are
or
Input The process of entering data and instructions into Stylus A stylus is an electronic pen that looks like a small
the computer system. ballpoint pen.
O
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 thousands or millions used to amplify and switch electronic signals. Although
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
Internet It is a network of networks that connects electronic signals.
EXERCISES
Fill in the Blanks 4. The speed of computers is expressed in ________ or
1. A program is the ________. ________.
2. Computers operate on ________ based on ________. 5. Raw facts or figures are called ________.
3. Computers can perform ________ calculations in a second. 6. ________ is an example of primary memory.
7. ________ and ________ are examples of first-generation 6. The brain of the computer is the
computing devices. (a) control unit (b) ALU
8. Second-generation computers were first developed for (c) CPU (d) All of these
the ________ industry.
9. ________ packages allow easy manipulation and analysis State True or False
of data organized in rows and columns. 1. Computers work on the GIGO concept.
10. CRAY-1, CRAY-2, Control Data CYBER 205, and ETA A-10 2. 1 nanosecond = 1×10−12 seconds.
are ________.
3. Floppy disks and hard disks are examples of primary
11. ________ 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
12. ________ connector is used to connect a monitor. transistors.
13. ________ concept was introduced by Sir John von 5. First-generation computers could be programmed only
Neumann in the late 1940s. in binary language.
14. Android Jellybean, Windows, and iOS are all examples of 6. ALGOL is used in the third generation of computers.
popular operating systems used in ________ and
7. Fifth-generation computers are based on AI.
________.
8. Network computers have more processing power,
15. ________ is an interface between the operating system
s
memory, and storage than a desktop computer.
es
and the motherboard.
9. RAM stores the data and parts of program, the
intermediate results of processing, and the recently
Multiple-choice Questions
Pr
generated results of jobs that are currently being worked
1. Which was the first commercial computer delivered to a on by the computer.
business client?
(a) UNIVAC
(c) EDSAC
(b) ENIAC
(d) None of these
s ity
10. A serial port is used to connect old printers.
Review Questions
2. Which technology was used to manufacture second- 1. Define a computer.
er
generation computers? 2. Differentiate between data and information.
(a) Vacuum tubes (b) Transistors 3. Differentiate between primary memory and secondary
iv
3. Time sharing operating systems were used in which 4. Write a short note on the characteristics of a computer.
generation of computers? 5. Computers work on the garbage-in, garbage-out
(a) First (b) Second concept. Comment.
d
(c) Third (d) Fourth 6. Explain the evolution of computers. Further, state how
computers in one generation are better than their
or
s
Characteristics 3 Debugging 158 scanf() 179
es
A Classification 9 Decision control Internet 12, 139
Adjacency list 481 Decision support statements 205 Chatting 142
Adjacency matrix 480 systems 15 Electronic mail 141
Pr
Algorithms 153 Expert systems 15 E Electronic newspaper 143
Array of function pointers 369 Generation 6 Efficient programs 152 File transfer protocol 142
Arrays 275, 337, 364, 461
Applications 308
Calculating the address 277
Geographic information
system 13
Mainframe computers 9
s ity
Enumerated data type 405
Errors 157
Internet conferencing 143
Internet protocol 139
World Wide Web 143
Declaration 275 Microcomputers 10 F Iteration 267
er
Elements 276 Minicomputers 9 File 415 Iterative statements 216
Operations 279 Robotics 15 in C 417 do-while loop 218
iv
Absorption law 80 Wide area network 125 ftell() 440 Logic gates 82
Associative law 79 Wireless 132 Function-like macros 448 and gate 83
O
s
Single-user multitasking 110 Processors 54 Optical drives 46
es
UNIX 115 Complex instruction set USB flash drives 48 T
Virtual machine 111 computer 54 Signed number representation TCP/IP model 138
Pr
Windows 113 Reduced instruction set in binary form 69 Temporary 442
Operator 182 computer 55 One’s complement 70 Testing 158
Arithmetic 183 Productivity software 97 Sign-and-magnitude 70 Tower of Hanoi 266
Assignment 189
Bitwise 187
Comma 189
Microsoft office 97
Programming languages 117
Generations 118
ity
Two’s complement 70
Sparse matrix 306
s
Array representation 307
Trees 477
Binary trees 478
Traversing 478
Conditional 187 Programming Stacks 471 Truth tables 77
er
Equality 185 paradigms 149 Operations on 473 Two-dimensional arrays 295,
Logical 185 Monolithic 149 Storage class 259 296, 297, 300, 302
iv
Precedence chart 191 Object-oriented 151 Auto 259 Accessing the elements 297
Un
Output devices 16, 29 Q String manipulation functions 332 Type conversion 195
or
Passing arrays 292 Recursion 265, 266, 267 strchr 332 Universal gates 85
Passing parameters 253 Direct 265 strcmp 333 NAND 85
Call by reference 254 Indirect 265 strcpy 333 NOR 86
Call by value 253 Linear 266 strcspn 335
perror() 425 Tail 265 strlen 334 V
Pointers 348 Tree 266 strncat 332 Variables 173, 257
and 2D arrays 365 Recursive function 262 strncmp 333 Block scope 257
and 3D arrays 367 Base case 262, 263 strncpy 334 File scope 259
and arrays 356 Exponent 264 strpbrk 335 Function scope 258
and strings 360 Fibonacci series 264 strrchr 333 Program scope 258
Drawbacks 375 GCD 263 strspn 334 Scope 257
Generic 354 Recursive case 262, 263 strstr 334 Venn diagrams 77