PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Computer

Fundamentals and
Programming in

s
es
Pr
s ity
er
iv
Un
d

Reema Thareja
or
xf

Assistant Professor
Department of Computer Science
O

Shyama Prasad Mukherji College for Women


University of Delhi

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd i 4/18/2016 2:42:14 PM



Oxford University Press is a department of the University of Oxford.
It furthers the University’s objective of excellence in research, scholarship,
and education by publishing worldwide. Oxford is a registered trade mark of
Oxford University Press in the UK and in certain other countries.

Published in India by
Oxford University Press
YMCA Library Building, 1 Jai Singh Road, New Delhi 110001, India

© Oxford University Press 2012, 2016

The moral rights of the author/s have been asserted.

First Edition published in 2012


Second Edition published in 2016

All rights reserved. No part of this publication may be reproduced, stored in


a retrieval system, or transmitted, in any form or by any means, without the

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.

You must not circulate this work in any other form

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

Printed in India by Magic International (P) Ltd., Greater Noida


Un

Third-party website addresses mentioned in this book are provided


by Oxford University Press in good faith and for information only.
Oxford University Press disclaims any responsibility for the material contained therein.
d
or
xf
O

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd ii 4/18/2016 2:42:15 PM


Features of
1 9
Introduction to Computers Introduction to C

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

Notes and Programming Tips


Computer
3/11/2016
fundamental_Ch10.indd
4:32:48 PM 205
ity
because they are used to modify the normal funcƟon of a
key. For example, ShiŌ + character (lowercase) makes the
3/11/2016 4:56:22 PM
s
computer display the character in upper case.
er
Notes highlight important terms and concepts,
Computer fundamental_Ch03.indd 39 Computer
3/11/2016
fundamental_Ch11.indd
4:33:30 PM 248 3/11/2016 4:58:22 PM

and programming tips educate the readers about


iv

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.

Computer fundamental_Ch01.indd 18 2/22/2016 6:39:01 PM


GLOSSARY
Glossary Impact printer A printer that works by striking an inked
ribbon against the paper
extracƟng data from marked Įelds, such as checkboxes
and Įll-in Įelds, on printed forms
Input device A device that is used to feed data and Output device A device that is used to present informaƟon

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

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd iv 4/18/2016 2:42:15 PM


the Book
CASE STUDY 1: Chapters 9 and 10
We have learnt the basics of programming in C language and
concepts to write decision-making programs, let us now apply
scanf("%d",&number); Case Studies
our learning to write some useful programs. ‹ˆſ—„‡”ʰʰɧŶŶ—„‡”ʴɪɧɧɧƀ
i tf ("\ INVALID NUMBER")
Select chapters on C include case studies that
CASE STUDY 2: Chapter 12
show how C can be used to create programs
INTRODUCTION TO SORTING (b) Compare 52 and 29. Since 52 > 29, swapping is do
demonstrating real-life applications
The term sorting means arranging the elements of the array 29, 52, 87, 63, 27, 19, 54
in some relevant order which may be either ascending or (c) Compare 52 and 87. Since 52 < 87, no swapping is

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

Questions Objective Questions


xf

Includes comprehensive exercises at the end of each


CHAPTER 1
chapter to facilitate revision—Answers to these
O

Fill in the Blanks


1. set of instructions executed by the computer; 2. data, instructions; 3. millions; 4. nano or pico seconds; 5. data;
questions are provided in Appendix F at the end of
6. RAM; 7. UNIVAC and ENIAC; 8. atomic energy; 9. Spreadsheet; 10. super computers; 11. Modem; 12. VGA
connector; 13. Stored program; 14 smartphones, tablets; 15. BIOS the book
MulƟple-choice QuesƟons
1. UNIVAC; 2. Transistors; 3. Third generation; 4. LISP, Prolog; 5. Network computer; 6. CPU

State True or False


1. True 2. False 3. False 4. False 5. True 6. False
7. True 8. False 9. True 10. True

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()ĨƵŶĐƟŽŶƌĞƚƵƌŶƐͺͺͺͺͺͺͺͺ͘
ϭϭ͘ ͺͺͺͺͺͺͺͺĨƵŶĐƟŽŶƉƌŝŶƚƐĚĂƚĂŽŶƚŚĞŵŽŶŝƚŽƌ͘  ;ĂͿ ϮϬ ;ďͿ Ͳϰ͘ϱ
; Ϳ ͚ ͛ ;ĚͿ

Computer fundamental_AppF.indd 516 4/18/2016 2:33:21 PM

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd v 4/22/2016 5:22:43 PM


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 a career in engineering and technology, but is also
mandatory for students of other professions such as journalism, nursing, archaeology, 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 modern-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

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.

ABOUT THE BOOK


s ity
This second edition of Computer Fundamentals and Programming in C has been designed as a textbook for the
er
undergraduate students of engineering, computer science, and computer applications. The objective of this book is to
introduce the readers to the elements of computing, computer hardware and software, and C programming.
iv

PEDAGOGICAL FEATURES
Un

The following are the salient features of the book:


Comprehensive coverage Provides comprehensive coverage of important topics ranging from the basics of computers
d

to C programming and important data structures


or

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.

NEW TO THIS EDITION


The following are the most notable additions in this:
• Introduces a chapter on Boolean Algebra and Logic Gates, which discusses the basic concepts underlying digital
computing systems
• Many new sections have been added in this edition. The details are as follows:

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.

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd vii 4/18/2016 2:42:34 PM


viii Preface to the Second Edition

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

CONTENT AND COVERAGE


Un

The book is divided into two parts spanning 18 chapters and five appendices.

Part I: Computers in Fundamentals


d

Chapter 1, Introduction to Computers, provides an introduction to computers. The chapter explains the generations,
or

classifications, applications, and the basic organization of a computer system.


Chapter 2, Input and Output Devices, presents a detailed description of the different types of input and output devices.
xf

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

(including RISC and CISC) and the instruction set.


Chapter 4, Number Systems and Computer Codes, discusses binary, octal, and hexadecimal number systems. The
chapter enables the reader to perform arithmetic operations on different number systems. Important codes such as ASCII,
EBCDIC, Excess 3, Gray code, and Unicode are also discussed in the chapter.
Chapter 5, Boolean Algebra and Logic Gates, introduces the concepts of digital computing systems such as Boolean
algebra, Boolean functions, Boolean expressions, and logic gates.
Chapter 6, Computer Software, provides a thorough overview of computer software. It discusses different types of
system software and application software packages that are widely used.
Chapter 7, Computer Networks and the Internet, talks about different types of computer networks, wired and wireless
media, network devices and topologies, area networks, and data transmission mode. It also discusses the Internet, TCP/
IP protocol, and different services provided by the Internet.
Chapter 8, Designing Efficient Programs, details the different steps in software development process, which are
performed for creating efficient and maintainable programs. It also explains the different tools, which are used to obtain
solution(s) of a given problem at hand.

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd viii 4/22/2016 5:22:49 PM


Preface to the Second Edition ix

Part II: Programming in C


Chapter 9, Introduction to C, discusses the building blocks of the C programming language. It includes descriptions on
identifiers, constants, variables, and operators supported by the language.
Annexure 1 shows the steps to write, compile, and execute a C program in Unix/Linux and Ubuntu environments.
Chapter 10, Decision Control and Looping Statements, deals with special types of statements such as decision control,
iterative, break, control, and jump.
Case Study 1 includes two programs which harness the concepts learnt in Chapters 9 and 10.
Chapter 11, Functions, deals with declaring, defining, and calling functions. It also discusses the storage classes as well
as variable scope in C. The chapter ends with the concept of recursion and a discussion of the Tower of Hanoi problem.
Annexure 2 discusses how to create user-defined header files.
Chapter 12, Arrays, provides a detailed explanation of arrays that includes one-dimensional, two-dimensional, and
multi-dimensional arrays. Towards the end of the chapter, the operations that can be performed on such arrays are also
explained.
Case Study 2 provides an introduction to sorting and various sorting techniques such as bubble sort, insertion sort, and
selection sort.

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

Annexure 4 provides an explanation about bit fields and slack bytes.


Un

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

the use of different directives in a C program.


or

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

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd ix 4/22/2016 5:22:51 PM


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.

ABOUT THE BOOK

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

tested have been included in the book.


To further enhance the understanding of the subject, there are numerous chapter-end exercises provided in the form of
Un

objective type questions, review questions, and programming problems.


The book is also useful as a reference and resource to computer professionals.
d

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

Technology and Management, Delhi.


My special thanks would always go to my father Shri Janak Raj Thareja, my mother Smt. Usha Thareja, my brother
O

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

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd x 4/18/2016 2:42:37 PM


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

PART I: COMPUTER FUNDAMENTALS 1


1 Introduction to Computers 3
2 Input and Output Devices 22
3 Computer Memory and Processors 39

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

10 Decision Control and Looping Statements 205


Un

11 Functions 248
12 Arrays 275
d

13 Strings 317
or

14 Pointers 347
xf

15 Structure, Union, and Enumerated Data Type 386


16 Files 415
O

17 Preprocessor Directives 447


18 Introduction to Data Structures 460

Appendix A: Bitwise Operations 488


Appendix B: ANSI C Library Functions 490
Appendix C: Advanced Type Qualifiers and Inline Functions in C 498
Appendix D: Interview Questions with Solutions 501
Appendix E: Linux: A Short Guide 511
Appendix F: Answers to Objective Questions 516
Index 523
About the Author 525

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd xi 4/20/2016 9:02:46 PM


Detailed Contents
Features of the Book iv
Companion Online Resources vi
Preface to the Second Edition vii
Preface to the First Edition x
Brief Contents xi

PART I: COMPUTER FUNDAMENTALS 1


1 Introduction to Computers 3 3.12.1 CD-ROM 47
1.1 Computer 3 3.12.2 DVD-ROM 47
1.2 Characteristics of Computers 3 3.12.3 CD-R 47
1.3 Stored Program Concept 4 3.12.4 CD-RW 47
1.3.1 Types of Stored Program Computers 4 3.12.5 BLU-Ray Disks 48

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

3.16.5 System Clock 53


2 Input and Output Devices 22
3.16.6 Processor Speed 53
Un

2.1 Input Devices 22


3.16.7 Pipelining and Parallel
2.1.1 Keyboard 22
Processing 54
2.1.2 Pointing Devices 23
3.16.8 Types of Processors 54
2.1.3 Handheld Devices 25
d

2.1.4 Optical Devices 26 4 Number Systems and Computer Codes 59


or

2.1.5 Audiovisual Input Devices 28 4.1 Introduction to Number Systems 59


2.2 Output Devices 29 4.2 Binary Number System 59
xf

2.2.1 Soft Copy Devices 29 4.3 Working With Binary Numbers 60


2.2.2 Hard Copy Devices 33 4.3.1 Converting a Binary Number into
O

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

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd xii 4/23/2016 1:31:25 PM


Detailed Contents xiii

4.4.5 Adding Two Octal Numbers 65 5.8.2 NOR Universal Gate 86


4.4.6 Subtracting Two Octal Numbers 65 5.9 Simplification of Boolean Expressions
4.5 Hexadecimal Number System 66 Using Karnaugh Map 87
4.5.1 Converting a Hexadecimal Number into
6 Computer Software 92
Decimal Form 66
6.1 Introduction to Computer Software 92
4.5.2 Converting a Decimal Number into
6.2 Classification of Computer Software 93
Hexadecimal Form 66
6.2.1 System Software 93
4.5.3 Converting a Hexadecimal Number into
6.2.2 Application Software 96
Binary Form 67
6.3 Acquiring Computer Software 96
4.5.4 Converting a Binary Number into
6.3.1 Buying Pre-written Software 96
Hexadecimal Form 67
6.3.2 Having Customized Software 96
4.5.5 Converting a Hexadecimal Number into
6.3.3 Downloading Public Domain
Octal Form 67
Software 97
4.5.6 Converting an Octal Number into
6.4 Productivity Software 97
Hexadecimal Form 67
6.4.1 Introduction to Microsoft Office 97
4.5.7 Adding Two Hexadecimal
6.5 Graphics Software 109
Numbers 68
6.6 Multimedia Software 109

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.2 Extended Binary Coded Decimal


6.12 Generation of Programming Languages 118
Interchange Code 71
6.12.1 First Generation: Machine
Un

4.9.3 Excess-3 Code 71


Language 118
4.9.4 Weighted Codes 71
6.12.2 Second Generation: Assembly
4.9.5 Gray Code 73
Language 118
d

4.9.6 Unicode 73
6.12.3 Third Generation: High-level
or

5 Boolean Algebra and Logic Gates 76 Language 119


5.1 Boolean Algebra 76 6.12.4 Fourth Generation: Very High-level
xf

5.2 Venn Diagrams 77 Language 119


5.3 Truth Tables 77 6.12.5 Fifth Generation Programming
O

5.4 Basic Laws of Boolean Algebra 78 Language 120


5.4.1 Identity Law 78
7 Computer Networks and the Internet 124
5.4.2 Idempotency Law 78
7.1 Introduction to Computer Networks 124
5.4.3 Complement Law 78
7.1.1 Advantages of Computer
5.4.4 Involution Law 78
Networks 124
5.4.5 Commutative Law 78
7.2 Types of Networks 125
5.4.6 Associative Law 79
7.2.1 Local Area Network 125
5.4.7 Distributive Law 79
7.2.2 Wide Area Network 125
5.4.8 Absorption Law 80
7.2.3 Metropolitan Area Network 125
5.4.9 Consensus Law 80
7.2.4 Campus/Corporate Area Network 126
5.4.10 De Morgan’s Laws 80
7.2.5 Personal Area Network 126
5.5 Representations of Boolean Functions 81
7.2.6 Peer-to-Peer Networks 126
5.5.1 Minterm 81
7.3 Physical Components of a Network 127
5.5.2 Maxterm 82
7.4 Wired Media 127
5.6 Logic Gates 82
7.4.1 Twisted-pair Wires 127
5.7 Logic Diagrams and Boolean Expressions 84
7.4.2 Coaxial Cables 127
5.8 Universal Gates 85
7.4.3 Fibre Optic Cables 127
5.8.1 NAND Universal Gate 85

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd xiii 4/18/2016 2:42:38 PM


xiv Detailed Contents

7.5 Wireless Media 128 7.13.1 Types of IP Addresses 139


7.5.1 Terrestrial Microwaves 128 7.14 Domain Name System 139
7.5.2 Satellite Communication 128 7.15 Uniform Resource Locator or Universal Resource
7.5.3 Infrared Communication 128 Locator 140
7.6 Networking Devices 128 7.16 Internet Services 141
7.6.1 Hub 128 7.16.1 Electronic Mail 141
7.6.2 Repeater 129 7.16.2 File Transfer Protocol 142
7.6.3 Switch 129 7.16.3 Chatting 142
7.6.4 Bridge 129 7.16.4 Internet Conferencing 143
7.6.5 Router 129 7.16.5 Electronic Newspaper 143
7.6.6 Gateway 130 7.16.6 World Wide Web 143
7.6.7 Network Interface Card 130 7.16.7 Online Shopping 143
7.7 Network Topologies 130 7.16.8 Search Engine 144
7.7.1 Bus Topology 130
8 Designing Efficient Programs 149
7.7.2 Star Topology 130
8.1 Programming Paradigms 149
7.7.3 Ring Topology 131
8.1.1 Monolithic Programming 149
7.7.4 Mesh topology 131
8.1.2 Procedural Programming 149

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

Protocol Model 138


8.4.2 FLOWCHARTS 154
7.12 Internet 138
8.4.3 Pseudocodes 156
Un

7.12.1 History 139


8.5 Types of Errors 157
7.13 Internet Protocol Address 139
8.6 Testing and Debugging Approaches 158
d
or

PART II: PROGRAMMING IN C 163


9 Introduction to C 165 9.11.1 How are Float and Double Stored? 173
xf

9.1 Introduction 165 9.12 Variables 173


9.1.1 Background 165 9.12.1 Numeric Variables 173
O

9.1.2 Characteristics of C 166 9.12.2 Character Variables 174


9.1.3 Uses of C 166 9.12.3 Declaring Variables 174
9.2 Structure of a C Program 166 9.12.4 Initializing Variables 174
9.3 Writing the first C Program 167 9.13 Constants 174
9.4 Files Used in a C Program 168 9.13.1 Integer Constants 174
9.4.1 Source Code Files 168 9.13.2 Floating Point Constants 175
9.4.2 Header Files 168 9.13.3 Character Constants 175
9.4.3 Object Files 169 9.13.4 String Constants 175
9.4.4 Binary Executable Files 169 9.13.5 Declaring Constants 175
9.5 Compiling and Executing C Programs 169 9.14 Input/Output Statements in C 176
9.6 Using Comments 170 9.14.1 Streams 176
9.7 C Tokens 171 9.14.2 Formatting Input/Output 176
9.8 Character Set in C 171 9.14.3 printf() 176
9.9 Keywords 171 9.14.4 scanf() 179
9.10 Identifiers 172 9.14.5 Examples of printf/scanf 180
9.10.1 Rules for Forming Identifier 9.14.6 Detecting Errors During Data Input 182
Names 172 9.15 Operators in C 182
9.11 Basic Data Types in C 172 9.15.1 Arithmetic Operators 183

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd xiv 4/18/2016 2:42:39 PM


Detailed Contents xv

9.15.2 Relational Operators 184 11.9.3 extern Storage Class 260


9.15.3 Equality Operators 185 11.9.4 static Storage Class 261
9.15.4 Logical Operators 185 11.9.5 Comparison of Storage Classes 262
9.15.5 Unary Operators 186 11.10 Recursive Functions 262
9.15.6 Conditional Operator 187 11.10.1 Greatest Common Divisor 263
9.15.7 Bitwise Operators 187 11.10.2 Finding Exponents 264
9.15.8 Assignment Operators 189 11.10.3 Fibonacci Series 264
9.15.9 Comma Operator 189 11.11 Types of Recursion 265
9.15.10 sizeof Operator 191 11.11.1 Direct Recursion 265
9.15.11 Operator Precedence Chart 191 11.11.2 Indirect Recursion 265
9.16 Type Conversion and Typecasting 195 11.11.3 Tail Recursion 265
9.16.1 Type Conversion 195 11.11.4 Linear and Tree Recursion 266
9.16.2 Typecasting 196 11.12 Tower of Hanoi 266
Annexure 1 204 11.13 Recursion Versus Iteration 267
Annexure 2 274
10 Decision Control and Looping Statements 205
10.1 Introduction to Decision Control 12 Arrays 275
Statements 205 12.1 Introduction 275

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

10.5.1 break Statement 232 Keyboard 278


10.5.2 continue Statement 232 12.4.3 Assigning Values to Individual
Un

10.6 goto Statement 233 Elements 278


Case Study 1: Chapters 9 and 10 245 12.5 Operations on Arrays 279
12.5.1 Traversing an Array 279
d

11 Functions 248
12.5.2 Inserting an Element in an Array 283
11.1 Introduction 248
or

12.5.3 Deleting an Element from an


11.1.1 Why are Functions Needed? 248
Array 286
11.2 Using Functions 249
xf

12.5.4 Merging Two Arrays 287


11.3 Function Declaration/Function Prototype 249
12.5.5 Searching for a Value in an
11.4 Function Definition 250
O

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

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd xv 4/18/2016 2:42:41 PM


xvi Detailed Contents

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

13.4.10 Extracting a Substring from the 15.1 Introduction 386


Middle of a String 328 15.1.1 Structure Declaration 386
Un

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 of a
d

13.4.13 Deleting a String from the Main Structure 388


or

String 330 15.1.5 Copying and Comparing


13.4.14 Replacing a Pattern with Another Structures 389
xf

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
O

Functions 331 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
14 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.10.1 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

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd xvi 4/18/2016 2:42:42 PM


Detailed Contents xvii

15.10.3 Assigning Values to Enumerated 17.2 Types of Preprocessor Directives 447


Variables 406 17.3 #define 447
15.10.4 Enumeration Type Conversion 406 17.3.1 Object-like Macro 448
15.10.5 Comparing Enumerated 17.3.2 Function-like Macros 448
Types 407 17.3.3 Nesting of Macros 449
15.10.6 Input/Output Operations on 17.3.4 Rules for Using Macros 449
Enumerated Types 407 17.3.5 Operators Related to Macros 450
Annexure 4 413 17.4 #include 450
17.5 #undef 451
16 Files 415
17.6 #line 451
16.1 Introduction to Files 415
17.7 #pragma 452
16.1.1 Streams in C 415
17.8 Conditional Directives 454
16.1.2 Buffer Associated with File
17.8.1 #ifdef 454
Streams 415
17.8.2 #ifndef 454
16.1.3 Types of Files 416
17.8.3 #if 455
16.2 Using Files in C 417
17.8.4 #else 455
16.2.1 Declaring a File Pointer Variable 417
17.8.5 #elif 455
16.2.2 Opening a File 417

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.5 Detecting the End-of-File 424 18.4 Linked Lists 461


16.6 Error Handling During File Operations 424 18.4.1 Traversing a Linked List 462
Un

16.6.1 clearerr() 425 18.4.2 Searching Linked List 462


16.6.2 perror () 425 18.4.3 Inserting a New Node in a Linked
16.7 Accepting Command Line Arguments 426 List 463
d

16.8 Functions for Selecting a Record 18.4.4 Deleting a Node from a Linked
or

Randomly 438 List 466


16.8.1 fseek() 438 18.5 Stacks 471
xf

16.8.2 ftell () 440 18.5.1 Operations on Stack 473


16.8.3 rewind () 440 18.6 Queues 475
O

16.8.4 fgetpos() 441 18.6.1 Operations on Queues 475


16.8.5 fsetpos() 441 18.7 Trees 477
16.9 Deleting a File 441 18.7.1 Representation of Binary Trees in
16.10 Renaming a File 442 Memory 478
16.11 Creating a Temporary File 442 18.7.2 Traversing a Binary Tree 478
18.8 Graphs 479
17 Preprocessor Directives 447
18.8.1 Representation of Graphs 480
17.1 Introduction 447

Appendix A: Bitwise Operations 488


Appendix B: ANSI C Library Functions 490
Appendix C: Advanced Type Qualifiers and Inline Functions in C 498
Appendix D: Interview Questions with Solutions 501
Appendix E: Linux: A Short Guide 511
Appendix F: Answers to Objective Questions 516
Index 523
About the Author 525

© Oxford University Press. All rights reserved.

Computer fundamental_FM.indd xvii 4/20/2016 9:08:03 PM


1
Introduction to Computers

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

even imagine a world without them.


Un

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

Therefore, they were used only for limited tasks, such


n
or

as computing trajectories for astronomical or military


applications. However, with technological advancements, Large
xf

the size of computers became smaller and their energy Diligence Computers
memory
requirements reduced immensely. This opened the way for
O

adoption of computers for commercial purposes.


These days, computers have become so prevalent in
A
ity

cc
til

ur

the market that all interactive devices such as cellular


sa

Speed

a
er

cy
V

phones, global positioning system (GPS) units, portable


organizers, automated teller machines (ATMs), and gas
pumps, work with computers.
Figure 1.1 Characteristics of computers

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

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 3 4/15/2016 10:39:59 AM


4 Computer Fundamentals and Programming in C

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

the same time. simultaneously. While data is being read/written, the


central processing unit (CPU) executes another program
Un

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

to record certain important things, computers also have


internal or primary memory (storage space) as well as A stored program architecture is a fundamental
or

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

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.
O

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

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 4 4/15/2016 10:40:03 AM


Introduction to Computers 5

Address Bus - carries addresses

Main
Processor Data Bus - carries data and instructions Memory

(a)

Instruction address Data address

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

at a time. Data and instructions are transferred to and


from memory through a shared data bus. Since there is a
s ity
China. It was used by the Babylonians even in 300 BC and
is still in use today (in the Far East).
single bus to carry data and instructions, process execution
er
1822: English mathematician Charles Babbage designed
becomes slower.
a steam-driven calculating machine that could compute
Later Harvard University proposed a stored program
iv

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
Un

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.
d

becomes faster. The system completed the task in three years saving the
or

US government $5 million. Later Herman established a


company that we today know as IBM.
xf

1.4 HISTORY OF COMPUTERS 1936: British mathematician Alan Turing introduced


a universal machine called the Turing machine capable
O

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.

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 5 4/15/2016 10:40:04 AM


6 Computer Fundamentals and Programming in C

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

1973: Robert Metcalfe, a research member at Xerox,


based, dual-core mobile computer.
developed Ethernet for connecting multiple computers
Un

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.

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 6 4/15/2016 10:40:05 AM


Introduction to Computers 7

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

Third Generation (1964–1975)


s ity
Hardware Technology Third generation computers were
manufactured using integrated chips (ICs) (shown in
er
Figure 1.5). ICs consist of several components such as
transistors, capacitors, and resistors on a single chip to
iv

avoid wired interconnections between components. These


computers used SSI and MSI technology. Minicomputers
Un

came into existence.


Figure 1.3 Vacuum tube
Note
Source: Vladyslav Danilin/Shutterstock
d

Initially, ICs contained 10–20 components. This


or

technology was called Small Scale Integration (SSI). Later,


Second Generation (1955–1964) it was enhanced to contain about 100 components. This
xf

was called MSI (Medium Scale Integration).


Hardware Technology Second generation computers
O

were manufactured using transistors (see Figure 1.4).


Transistors were reliable, powerful, cheaper, smaller, and Memory Larger magnetic core memory was used as
cooler than vacuum tubes. primary memory; larger capacity magnetic tapes and
magnetic disks were used to store data and instructions.
Memory Magnetic core memory was used as primary
memory; magnetic tapes and magnetic disks were used Software Technology Programming was done in high level
to store data and instructions. These computers had faster programming languages such as FORTRAN, COBOL,
and larger memory than the first generation computers. Pascal, and BASIC. Time sharing operating system was
used. Software was separated from the hardware. This
Software Technology Programming was done in high allowed users to invest only in the software they need.
level programming languages. Batch operating system
was used. Used for Scientific, commercial, and interactive online
applications
Used for Scientific and commercial applications
Examples IBM 360/370, PDP-8, PADP-11, CDC6600
Examples Honeywell 400, IBM 7030, CDC 1604,
Highlights
UNIVAC LARC
• Faster, smaller, cheaper, reliable, and easier to use than
Highlights the second generation computers
• Faster, smaller, cheaper, reliable, and easier to use than • They consumed less power than second generation
the first generation computers computers

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 7 4/15/2016 10:40:07 AM


8 Computer Fundamentals and Programming in C

• 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

speed computer networks in the form of LANs, WANs,


and MANs started growing. Besides mainframes, Note
Un

supercomputers were also used


ULSI circuits contain about 10 million electronic
components on a single chip.
Note
d

LSI circuits contained 30,000 components on a single chip


Memory Semiconductor memory is used as primary
or

and VLSI technology had about one million electronic


memory; large capacity magnetic disks are used as built-in
components on a single chip.
secondary memory. Magnetic tapes and floppy disks were
xf

used as portable storage devices, which have now been


Memory Semiconductor memory was used as primary replaced by optical disks and USB flash drives.
O

memory, large capacity magnetic disks were used as built-


in secondary memory. Magnetic tapes and floppy disks Software Technology Programming is done in high-level
were used as portable storage devices. programming languages such as Java, Python, and C#.
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
(e.g. Windows) was introduced. It had icons and menus generations.
among other features to allow computers to be used as
a general purpose machine by all users. UNIX was also Used for Scientific, commercial, interactive online,
introduced as an open source operating system. Apple Mac multimedia (graphics, audio, video), and network applications
OS and MS DOS were also released during this period. All Examples IBM 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 IBM PC, Apple II, TRS-80, VAX 9000, CRAY- • Speed of microprocessors and the size of memory are
1, CRAY-2, CRAY-X/MP growing rapidly

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 8 4/15/2016 10:40:08 AM


Introduction to Computers 9

• 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

• Mainframe computers Mainframe computers are typically used as servers on


• Minicomputers the World Wide Web. They are also used in organizations
Un

• 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
d

mainframe computers. Some examples of mainframe


Among the four categories, the supercomputer is the
or

computers include IBM S/390, Control Data CYBER 176,


fastest, most powerful, and most expensive computer. and Amdahl 580.
Supercomputers were first developed in the 1980s to
xf

process large amounts of data and to solve complex


scientific problems. Supercomputers use parallel
1.5.3 Minicomputers
O

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

Supercomputers Mainframe computers Minicomputers Microcomputers

Dumb terminals Intelligent terminals Desktop PCs Laptops Handheld devices

Workstations Network computers

Figure 1.8 Classification of computers

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 9 4/15/2016 10:40:09 AM


10 Computer Fundamentals and Programming in C

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

classified into the following categories:


Un

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 (including the Internet and intranet).


Some network computers do not have any storage space
O

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.

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 10 4/15/2016 10:40:12 AM


Introduction to Computers 11

Handheld Computers • Watching movies


• Playing games
The mid-1990s witnessed a range of small personal • Sharing pictures, video, songs, documents, etc.
computing devices that are commonly known as handheld • Browsing the Internet
computers, or mobile computers. These computers are • Keeping in touch with friends and family on popular
called handheld computers because they can fit in one social networks, sending emails
hand, while users can use the other hand to operate them. • Business people use them to perform tasks such as
Handheld computers are very small in size, and hence they editing a document, exchanging documents, taking
have small-sized screens and keyboards. These computers notes, and giving presentations
are preferred by business travellers and mobile employees • Tablets are best used in crowded places such as airports
whose jobs require them to move from place to place. and coffee shops, where size and portability become
Some examples of handheld computers are as follows: more important.
• Smartphones
• Tablet PCs Note

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

from a camera to a web browser to a high-density display.


Un

Tablet PCs A tablet PC (see Figure 1.10) is a computing


device that is smaller than a laptop, but bigger than a
smartphone. Features such as user-friendly interface,
Figure 1.10 Tablet
d

portability, and touch screen have made them very


popular in the last few years. These days, a wide range Source: bloomua/Shutterstock/OUP Picture Bank
or

of high-performance tablets are available in the market.


While all of them look similar from outside, they may 1.6 APPLICATIONS OF COMPUTERS
xf

differ in features such as operating system, speed of data


connectivity, camera specifications, size of the screen, When the first computers were developed, they were used
O

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

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 11 4/19/2016 2:17:08 PM


12 Computer Fundamentals and Programming in C

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

buying and selling of goods and services using computers


and the Internet. Use of email and videoconferencing Bioinformatics
Un

technology has revolutionized the way business is being


conducted these days. Bioinformatics is the application of computer technology
While an e-mail is a service that delivers messages to manage large amount of biological information.
Computers are used to collect, store, analyse, and integrate
d

from a sender to one or more receivers via computer,


voice mail systems capture, store, and transmit spoken biological and genetic information to facilitate gene-based
or

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

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 12 4/15/2016 10:40:19 AM


Introduction to Computers 13

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

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
Un

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

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. Meteorology 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
number of 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.

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 13 4/15/2016 10:40:20 AM


14 Computer Fundamentals and Programming in C

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

Multimedia and animation that combines still images,


moving images, text, and sound in meaningful ways is
s ity
inventory of the products available and their complete
description.

one of most powerful aspects of computer technology. We Sports


er
all have seen cartoon movies, which are nothing but an
example of computer animation. In sports, computers are used to compile statistics,
iv

identify weak players and strong players by analysing


Un

statistics, sell tickets, create training programs and diets


Note
for athletes, and suggest game plan strategies based on
Displaying a number of still images within a fraction of a the competitor’s past performance. Computers are also
second gives an animation effect. For example, displaying used to generate most of the graphic art displays flashed
d

at least 30 still images in a second gives an effect of a on scoreboards.


or

moving image. Television networks use computers in the control room


to display action replays and insert commercial breaks as
xf

Using animation software, we can reproduce real- per schedule.


world phenomena such as fire, smoke, fluids, movement of In addition, there are simulation software packages
O

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.

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 14 4/15/2016 10:40:21 AM


Introduction to Computers 15

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

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
Un

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
d

Computerized process control (with or without human online, find your batchmates, send and receive greetings
or

intervention) is used to enhance efficiency in applications pertaining to different occasions, etc.


such as production of various chemical products, oil
xf

refining, paper manufacture, and rolling and cutting steel


to customer requirements. 1.7 BASIC ORGANIZATION OF
O

In CAD, computers and graphics-oriented software are


integrated for automating the design and drafting process.
A COMPUTER
It helps an engineer to design a 3D machine part, analyse
its characteristics, and then subject it to simulated stresses. A computer is an electronic device that performs five
In case a part fails the stress test, its specifications can be major operations:
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

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 15 4/15/2016 10:40:22 AM


16 Computer Fundamentals and Programming in C

Data and
instructions Input Storage Output Results

CPU
Control unit

Arithmetic and
Flow of data and instructions
logical unit
Control exercised by control unit

Figure 1.11 Block diagram of a computer

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

output, and storage) of the computer system.


and the recently generated results of jobs that are currently
or

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.

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 16 4/15/2016 10:40:24 AM


Introduction to Computers 17

Optional gigabit
PS/2 mouse Parallel Ethernet ethernet SGI image Sync

PS/2 Keyboard USB Serial 1 Serial 2 Graphics Secondary ethernet Sound card

Figure 1.12 Computer case and its parts

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

CPU. More memory means more applications can be


executed at the same time without degrading the system’s Fans There are one or more fans inside the computer to
performance. keep the air moving and the computer cool.
d

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

documents, and programs are stored on the hard disk. computer.


The larger the hard disk, the more the amount of data that
O

can be stored on the drive. Though the size of the HDD


does not affect the speed of execution of the program, it 1.9 MOTHERBOARD
does affect the speed at which the user can access his/
her files. The motherboard, also known as the mainboard or the
Video card The video card is a board that plugs into parent board (refer Figure 1.13), is the primary component
the motherboard of the computer and generates images of a computer. It is used to connect all the components
for display. Many video cards these days have their own of the computer. The motherboard is a printed circuit that
RAM and processor to enhance the speed of the graphics has connectors for expansion cards, memory modules, the
display. Many computers come with an in-built video chip. processor, etc.
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
Sound card 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

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 17 4/20/2016 9:04:59 PM


18 Computer Fundamentals and Programming in C

Input–Output connectors

Audio chip

PCI extension slots

AGP Motherboard power supply connector

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

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
quality of audio and visual capabilities, then you must
components are integrated into its printed circuitry. These
disable the graphics/audio chip in the BIOS setup and
include the following:
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 a 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 each

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 18 4/15/2016 10:40:26 AM


Introduction to Computers 19

Parallel Line in
Mouse
Line out

Keyboard Microphone

USB Series VGA USB


Figure 1.14 I/O connectors

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

Port) is a fast port used for graphics cards.


Processor socket The processor (also called the micro- I/O connectors The motherboard has a number of input–
Un

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

The slot on the motherboard into which the processor is


inserted is called the processor socket or slot. Irrespective • USB ports to connect more recent peripherals such as
of whether you use a slot or a socket, you must gently mouse and pen drive.
xf

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

hundreds of them). Usually, a concept called zero insertion


force (ZIF) is used. The ZIF sockets allow the processor to a network card integrated into the motherboard.
be inserted very gently and easily. • Video graphics array (VGA) connector to connect a
When the computer is on, the processor is working monitor. This connector interfaces with the built-in
and it releases heat, which must be dissipated to keep the graphics card.
circuits from melting. Therefore, the processor is generally • Audio plugs that include the line in, line out, and
mounted on a cooler that is made of metal (such as copper microphone to connect sound speakers, hi-fi system, or
or aluminum), which conducts heat well. In addition to the microphone. This connector interfaces with the built-in
cooler, there is also a fan to improve air circulation around sound card.

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.

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 19 4/15/2016 10:40:28 AM


20 Computer Fundamentals and Programming in C

• 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

properties of semiconductor materials (such as silicon


Garbage-in, garbage-out If input data is wrong, then the and germanium). The conductivity of such devices can be
Un

output will also be erroneous. controlled by introducing an electric field, by exposure to


GUI A GUI is a type of user interface that enables users to light, and even pressure and heat, thereby making such
interact with programs in more ways than typing. A GUI devices excellent sensors.
d

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

permanently in the computer so that it can be used for


performed by direct manipulation of the graphical elements. processing.
xf

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.

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 20 4/15/2016 10:40:29 AM


Introduction to Computers 21

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

(c) ICs (d) None of these memory.


Un

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

4. Choose the computer languages that are specially


predecessors.
designed for the fifth generation of computers.
7. Broadly classify computers based on their speed, the
xf

(a) ALGOL (b) SNOBOL


amount of data that they can hold, and price.
(c) LISP (d) Prolog
O

8. Discuss the variants of microcomputers that are widely


5. Web TV is an example of used today.
(a) supercomputer (b) minicomputer 9. Explain the areas in which computers are being applied
(c) network Computer (d) laptop to carry out routine and highly-specialized tasks.

© Oxford University Press. All rights reserved.

Computer fundamental_Ch01.indd 21 4/15/2016 10:40:31 AM


Index
#define 447 Compiling and executing 169 Data structures 460 I
#elif 455 C tokens 171 Linear and non-linear 460 Identifiers 172
#else 455 Uses 166 Primitive and non-primitive Input devices 16, 22, 28
#endif Directive 456 Character manipulation func- 460 Audiovisual 28
#ifdef 454 tions 331 Data transmission 133 Handheld 25
#if Directive 455 clearerr() 425 Asynchronous 135 Keyboard 22
#ifndef 454 Comments 170 Parallel 134 Optical 26
#include 450 Computer, 3, 4, 5, 9, 11, Serial 134 Pointing 23
#line 451 15, 16 Simplex, half-duplex, and Input/Output statements 176
#pragma 452 Application 11 full-duplex 133 Formatting input/output 176
#undef 451 Bioinformatics 12 Synchronous 135 printf() 176

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

Supercomputers 9 File mode 417 for loop 221


B Computer networks 124 Floating point constant 175 while loop 216
Un

BCD code 70 Connecting media 127 Character constant 175


ASCII code 71 Local area network 125 String constant 175 K
EBCDIC 71 Metropolitan area network Flowchart 154 Karnaugh map 87
d

Excess-3 code 71 125 fprintf() 421 Keywords 171


or

Gray code 73 Networking devices 128 fputs () 422


Unicode 73 Network topologies 130 fscanf() 418 L
Boolean algebra 76 Search engine 144 fsetpos() 441 Linked list 461, 463, 466
xf

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

Basic laws 78 Computer software 92 Function pointers 368 NOR gate 83


Commutative law 78 Application software 96 Functions 248, 249, NOT gate 83
Complement law 78 Customized 96 250, 251
Consensus law 80 Pre-written 96 Call 251 M
De Morgan’s laws 80 Public domain 97 Declaration 249 Macros 450
Distributive law 79 System software 93 Definition 250 Operators 450
Idempotency law 78 Conditional branching Prototype 249 Mass storage devices 50
Identity law 78 statements 205 Automated tape library 50
Involution law 78 if–else–if statement 209 G CD-Rom jukebox 50
Boolean expressions 84 if–else statement 207 goto statement 233 Disk array 50
Boolean functions 81 if statement 205 Graph 479 Memory 39
Maxterm 82 switch case 212 Graphics software 109 Cache 40
Minterm 81 Conditional directives 454 Graph terminology 480 Hierarchy 39
Break statement 232 Constants 174 Adjacent or Primary memory 40
Continue statement 232 neighbours 480 Memory allocation 370
C Degree of a node 480 Dynamic 371
C 166, 167, 168 D Motherboard 17
Characteristics 166 Database management H Multidimensional 305
Character set 171 software 109 Hard disk 17 Multimedia software 109

© Oxford University Press. All rights reserved.

Computer fundamental_Index.indd 523 4/19/2016 5:02:53 PM


524 Computer Fundamentals and Programming in C

N Null 354 Return statement 252 strtod 336


Nested loops 224 Pointer arithmetic 350 Rewind() 440 strtok 335
Nested structure 392 Pointer expressions 350 strtol 335
Number systems 59 Pointers to pointers 370 S Strings 318, 319, 322, 337
Binary 59 Preprocessor directives 447 Searching 289 Operations 322
Hexadecimal 66 Processor 40 Binary search 290 Reading 318
Octal 63 Random access memory 41 Linear search 289 Writing 319
Read-only memory 41 Secondary storage String taxonomy 322
O Registers 40 devices 42 Delimited 322
Object-like macro 448 Processor architecture 51 Blu-ray disks 48 Fixed-length 322
Operating systems 110 Execution unit 51 CD-R 47 Length-controlled 322
Batch processing 110 Instruction cycle 52 CD-ROM 47 Variable-length 322
Linux 116 Instruction set 52 CD-RW 47 Structure 386
Microsoft DOS 112 Pipelining and parallel DVD-ROM 47 and functions 395
Mobile 116 processing 54 Floppy disks 43 Arrays of 393
Multiprocessing 111 Processor speed 53 Hard disks 44 Inside unions 404
Multi-user multitasking 111 Registers 51 Magnetic tapes 43 Self-referential 402
Real-time 111 System clock 53 Memory cards 49 Suppressing input 321

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

Relational 184 Procedural 149 Extern 260 Declaring 295


sizeof 191 Structured 150 Register 260 Initializing 296
Unary 186 Pseudocode 156 Static 261 Operations 300
OSI model 136 Stream 176, 415 Typecasting 195, 196
d

Output devices 16, 29 Q String manipulation functions 332 Type conversion 195
or

Hard copy 33 Queues 475 atof() 336


Soft copy 29 Operations on 475 atoi() 336 U
xf

atol() 336 Unions 402


P R strcat 332 Inside structures 404
O

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

© Oxford University Press. All rights reserved.

Computer fundamental_Index.indd 524 4/19/2016 5:02:53 PM

You might also like