0% found this document useful (0 votes)
13 views

Emassfile 17

Uploaded by

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

Emassfile 17

Uploaded by

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

Programming for Problem Solving E

Balagurusamy
Visit to download the full and correct content document:
https://ebookmass.com/product/programming-for-problem-solving-e-balagurusamy/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Problem Solving and Python Programming E. Balagurusamy

https://ebookmass.com/product/problem-solving-and-python-
programming-e-balagurusamy/

Computer Programming E. Balagurusamy

https://ebookmass.com/product/computer-programming-e-
balagurusamy/

Programming in C E. Balagurusamy

https://ebookmass.com/product/programming-in-c-e-balagurusamy/

Programming in ANSI C 6th Edition E. Balagurusamy

https://ebookmass.com/product/programming-in-ansi-c-6th-edition-
e-balagurusamy/
Programming and Problem Solving with Python Ashok
Namdev Kamthane

https://ebookmass.com/product/programming-and-problem-solving-
with-python-ashok-namdev-kamthane/

Python Programming: Using Problem Solving Approach 1st


Edition Reema Thareja

https://ebookmass.com/product/python-programming-using-problem-
solving-approach-1st-edition-reema-thareja/

Introduction to Programming with Java: A Problem


Solving Approach 3rd Edition John Dean

https://ebookmass.com/product/introduction-to-programming-with-
java-a-problem-solving-approach-3rd-edition-john-dean/

MATLAB: A Practical Introduction to Programming and


Problem Solving 4th Edition Stormy Attaway

https://ebookmass.com/product/matlab-a-practical-introduction-to-
programming-and-problem-solving-4th-edition-stormy-attaway/

Data Structures E. Balagurusamy

https://ebookmass.com/product/data-structures-e-balagurusamy/
PROGRAMMING
fOR
PRObleM SOlvING
Gujarat Technological University - 2018
About the Author

E Balagurusamy, is presently the Chairman of EBG Foundation, Coimbatore. In the past he has also held
the positions of member, Union Public Service Commission, New Delhi and Vice-Chancellor, Anna University,
Chennai. He is a teacher, trainer and consultant in the fields of Information Technology and Management.
He holds an ME (Hons) in Electrical Engineering and PhD in Systems Engineering from the Indian Institute
of Technology, Roorkee. His areas of interest include Object-Oriented Software Engineering, E-Governance:
Technology Management, Business Process Re-engineering and Total Quality Management.
A prolific writer, he has authored a large number of research papers and several books.
A recipient of numerous honors and awards, he has been listed in the Directory of Who's Who of Intellectuals
and in the Directory of Distinguished Leaders in Education.
PROGRAMMING
fOR
PRObleM SOlvING
Gujarat Technological University - 2018

E Balagurusamy
Chairman
EBG Foundation
Coimbatore

McGraw Hill Education (India) Private Limited


CHENNAI

McGraw Hill Education Offices


Chennai New York St Louis San Francisco Auckland Bogotá Caracas
Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal
San Juan Santiago Singapore Sydney Tokyo Toronto
McGraw Hill Education (India) Private Limited
Published by McGraw Hill Education (India) Private Limited
444/1, Sri Ekambara Naickr Industrial Estate, Alapakkam, Porur, Chennai-600 116

Programming for Problem Solving


Copyright © 2019 by McGraw Hill Education (India) Private Limited.
No part of this publication may be reproduced or distributed in any form or by any means, electronic, mechanical,
photocopying, recording, or otherwise or stored in a database or retrieval system without the prior written permission of
the publishers. The program listings (if any) may be entered, stored and executed in a computer system, but they may not
be reproduced for publication.
This edition can be exported from India only by the publishers,
McGraw Hill Education (India) Private Limited.
Print Edition
ISBN (13 digit): 978-93-5316-278-8
ISBN (10 digit): 93-5316-278-5
E-book Edition
ISBN (13 digit): 978-93-5316-279-5
ISBN (10 digit): 93-5316-279-3
1 23456789 D101417 22 21 20 19 18
Printed and bound in India.
Director—Science & Engineering Portfolio: Vibha Mahajan
Senior Portfolio Manager—Science & Engineering: Hemant K Jha
Associate Portfolio Manager —Science & Engineering: Tushar Mishra
Production Head: Satinder S Baveja
Copy Editor: Taranpreet Kaur
Assistant Manager—Production: Suhaib Ali
General Manager—Production: Rajender P Ghansela
Manager—Production: Reji Kumar

Information contained in this work has been obtained by McGraw Hill Education (India), from sources believed to be
reliable. However, neither McGraw Hill Education (India) nor its authors guarantee the accuracy or completeness of any
information published herein, and neither McGraw Hill Education (India) nor its authors shall be responsible for any errors,
omissions, or damages arising out of use of this information. This work is published with the understanding that McGraw
Hill Education (India) and its authors are supplying information but are not attempting to render engineering or other
professional services. If such services are required, the assistance of an appropriate professional should be sought.

Typeset at The Composers, 260, C.A. Apartment, Paschim Vihar, New Delhi 110 063 and printed at

Cover Printer:
Cover Designer: APS Compugraphics
Cover Image Source: Shutterstock
Visit us at: www.mheducation.co.in
Write to us at: [email protected]
CIN: U22200TN1970PTC111531
Toll Free Number: 1800 103 5875
Preface

P
rogramming for Problem Solving requires a deep understanding of C. C is a powerful, flexible, portable
and elegantly structured programming language. Since C combines the features of high-level language
with the elements of the assembler, it is suitable for both systems and applications programming. It
is undoubtedly the most widely used general-purpose language today in operating systems, and embedded
system development. Its influence is evident in almost all modern programming languages. Since its
standardization in 1989, C has undergone a series of changes and improvements in order to enhance the
usefulness of the language.

Organization of the Book


Programming for Problem Solving starts with an Introduction to Computer Programming, Chapter 2 discusses
fundamentals of C. Control Structures in C is presented in Chapter 3. Chapter 4 deals with Arrays and
Strings. Chapter 5 discusses Functions. In Chapter 6 students can study Pointers. While Chapter 7 details
Structure. Dynamic Memory Allocation is discussed in Chapter 8. Chapter 9 details on File Management.

Salient Features of the Book


∑ Learning Objectives
∑ Key Concepts
∑ Content Tagged with LO
∑ Worked Out Problems
∑ Tips
∑ Closing Vignette
∑ Review Exercises – True False, Fill in the blanks, Questions, Programming Exercises – categorized into
LO and Difficulty level (E for Easy, M for Medium and H for High)

Acknowledgements
I owe special thanks to the entire team of McGraw Hill Education India.
A note of acknowledgement is due to the following reviewers for their valuable feedback.

Ms. Kalpana Mudaliar Gandhinagar Institute of Technology, Gandhinagar, Gujarat


H K Patnaik Kalinga Institute of Industrial Technology, KIIT University, Bhubaneswar
T V Gopal College of Engineering, Anna University, Chennai, Tamil Nadu
Unnati Nitin Chaudhari Tolani Maritime Institute, Pune, Maharashtra
Tanveer Ahmed Jamia Millia Islamia, Delhi
Ravindra Divekar KJ Somaiya College of Engineering, Mumbai, Maharashtra
SC Dutta Birsa Institute of Technology, Sindri, Dhanbad, Jharkhand
D Lakshmi Adithya Institute of Technology, Coimbatore, Tamil Nadu
vi Preface

This book is my sincere attempt to make a footprint on the immensely vast and infinite sands of knowledge.
I would request the readers to utilize this book to the maximum extent.
E Balagurusamy

Publisher’s Note
McGraw Hill Education (India) invites suggestions and comments from you, all of which can be sent to info.
[email protected] (kindly mention the title and author name in the subject line).
Piracy-related issues may also be reported.
Contents

About the Author ii


Preface v

1. Introduction to Computer and Programming 1


Learning Objectives 1
Introduction 1
Generations of Computers 2
Classification of Computers 5
Basic Anatomy of a Computer System 7
Input Devices 8
Processor 9
Output Devices 10
Memory Management 12
Types of Computer Software 13
Overview of Operating System 14
MS Word 19
MS Excel System 21
MS Powerpoint System 22
Networking Concepts 23
Network Topologies 25
Network Protocols and Software 29
Decimal System 31
Binary System 32
Hexadecimal System 33
Octal System 34
Conversion of Numbers 35
Binary Arithmetic Operations 44
Logic Gates 52
Programming Languages 55
viii Contents

Translator Programs 58
Problem-Solving Techniques 59
Using the Computer 70
Learning Outcomes 70
Key Concepts 71
Review Questions 73
Discussion Questions 84

2. Fundamentals of C 87
Learning Objectives 87
History of C 87
Importance of C 89
Sample Program 1: Printing a Message 89
Sample Program 2: Adding Two Numbers 92
Sample Program 3: Interest Calculation 93
Sample Program 4: Use of Subroutines 95
Sample Program 5: Use of Math Functions 96
Basic Structure of C Programs 97
Programming Style 98
Executing a ‘C’ Program 99
UNIX System 99
MS-DOS System 102
Key Concepts 102
Always Remember 103
Review Questions 103
Debugging Exercises 105
Programming Exercises 105

3. Control Structure in C 107


Learning Objectives 107
Introduction 107
Decision Making with if Statement 108
Simple If Statement 108
The If.....Else Statement 111
Nesting of If....Else Statements 114
The Else If Ladder 117
The Switch Statement 121
The ? : Operator 125
The goto Statement 129
Key Concepts 132
Contents ix

Always Remember 132


Brief Cases 132
Review Questions 137
Debugging Exercises 141
Programming Exercises 141

4. Array & String 145


Learning Objectives 145
Introduction 145
One-Dimensional Arrays 147
Declaration of One-dimensional Arrays 148
Initialization of One-dimensional Arrays 151
Two-Dimensional Arrays 156
Initializing Two-dimensional Arrays 161
Multi-dimensional Arrays 168
Dynamic Arrays 169
More About Arrays 170
Declaring and Initializing String Variables 170
Reading Strings from Terminal 171
Writing Strings to Screen 177
Arithmetic Operations on Characters 181
Putting Strings Together 183
Comparison of Two Strings 184
String-Handling Functions 184
Table of Strings 190
Other Features of Strings 192
Key Concepts 192
Always Remember 193
Brief Cases 194
Review Questions 210
Debugging Exercises 214
Programming Exercises 215

5. Functions 220
Learning Objectives 220
Introduction 220
Need for User-Defined Functions 221
A Multi-Function Program 221
Elements of User-Defined Functions 224
x Contents

Definition of Functions 224


Return Values and Their Types 227
Function Calls 228
Function Declaration 229
Category of Functions 231
No Arguments and No Return Values 231
Arguments but No Return Values 233
Arguments with Return Values 236
No Arguments but Returns a Value 241
Functions that Return Multiple Values 242
Nesting of Functions 243
Recursion 244
Passing Arrays to Functions 245
Passing Strings to Functions 250
The Scope, Visibility and Lifetime of Variables 251
Multifile Programs 260
Key Concepts 262
Always Remember 262
Brief Cases 263
Review Questions 266
Debugging Exercises 270
Programming Exercises 270

6. Pointers 273
Learning Objectives 273
Introduction 273
Understanding Pointers 274
Accessing the Address of a Variable 276
Declaring Pointer Variables 277
Initialization of Pointer Variables 278
Accessing a Variable Through its Pointer 279
Chain of Pointers 281
Pointer Expressions 282
Pointer Increments and Scale Factor 284
Pointers and Arrays 284
Pointers and Character Strings 288
Array of Pointers 290
Pointers as Function Arguments 291
Functions Returning Pointers 294
Contents xi

Pointers to Functions 295


Pointers and Structures 297
Troubles with Pointers 299
Key Concepts 300
Always Remember 300
Brief Cases 301
Review Questions 306
Debugging Exercises 309
Programming Exercises 309

7. Structure 311
Learning Objectives 311
Introduction 311
Defining a Structure 312
Declaring Structure Variables 313
Accessing Structure Members 315
Structure Initialization 316
Copying and Comparing Structure Variables 318
Operations on Individual Members 320
Arrays of Structures 320
Arrays within Structures 323
Structures within Structures 324
Structures and Functions 326
Unions 329
Size of Structures 330
Bit Fields 330
Key Concepts 333
Always Remember 333
Brief Cases 334
Review Questions 338
Debugging Exercises 341
Programming Exercises 341

8. Dynamic Memory Allocation 344


Learning Objectives 344
Introduction 344
Dynamic Memory Allocation 344
Allocating a Block of Memory: malloc 345
Allocating Multiple Blocks of Memory: calloc 347
xii Contents

Releasing the Used Space: free 348


Altering the Size of a Block: realloc 348
Concepts of Linked Lists 350
Advantages of Linked Lists 353
Types of Linked Lists 354
Pointers Revisited 354
Creating a Linked List 356
Inserting an Item 360
Deleting an Item 363
Application of Linked Lists 365
Key Concepts 365
Always Remember 366
Brief Cases 366
Review Questions 372
Debugging Exercises 374
Programming Exercises 374

9. File Management 376


Learning Objectives 376
Introduction 376
Defining and Opening a File 377
Closing a File 378
Input/Output Operations on Files 379
Error Handling During I/O Operations 385
Random Access to Files 387
Command Line Arguments 394
Key Concepts 396
Always Remember 396
Review Questions 397
Debugging Exercises 398
Programming Exercises 398
Roadmap to the Syllabus
Programming For Problem Solving
Code: 3110003

Introduction to computer and programming: Introduction, Basic block diagram and functions of various
components of computer, Concepts of Hardware and software, Types of software, Compiler and interpreter,
Concepts of Machine level, Assembly level and high level programming, Flowcharts and Algorithms

GO TO Chapter 1 Introduction to Computer and Programming

Fundamentals of C: Features of C language, structure of C Program, comments, header files, data types,
constants and variables, operators, expressions, evaluation of expressions, type conversion, precedence
and associativity, I/O functions

GO TO Chapter 2 Fundamentals of C

Control structure in C: Simple statements, Decision making statements, Looping statements, Nesting of
control structures, break and continue, goto statement

GO TO Chapter 3 Control Structure in C

Array & String: Concepts of array, one and two dimensional arrays, declaration and initialization of arrays,
string, string storage, Built-in-string functions
Recursion: Recursion, as a different way of solving problems. Example programs, such as Finding
Factorial, Fibonacci series, Ackerman function etc. Quick sort or Merge sort.

GO TO Chapter 4 Array & String


xiv Roadmap to the Syllabus

Functions: Concepts of user defined functions, prototypes, definition of function, parameters, parameter
passing, calling a function, recursive function, Macros, Pre-processing

GO TO Chapter 5 Functions

Pointers: Basics of pointers, pointer to pointer, pointer and array, pointer to array, array to pointer, function
returning pointer

GO TO Chapter 6 Pointers

Structure: Basics of structure, structure members, accessing structure members, nested structures, array
of structures, structure and functions, structures and pointers

GO TO Chapter 7 Structure

Dynamic memory allocation: Introduction to Dynamic memory allocation, malloc, calloc

GO TO Chapter 8 Dynamic Memory Allocation

File management: Introduction to file management and its functions

GO TO Chapter 9 File Management


Introduction to
Chapter
Computer and
Programming 1
LEARNING OBJECTIVES
LO 1.1 Identify the various generations of computers
LO 1.2 Classify computers on the basis of different criteria
LO 1.3 Describe the computer system
LO 1.4 Classify various computer software
LO 1.5 Discuss various operating systems
LO 1.6 Discuss Microsoft software
LO 1.7 Know various networking concepts and protocols
LO 1.8 Identify the various positional number systems
LO 1.9 Carry out number conversions from one number system to another
LO 1.10 Explain how binary arithmetic operations are performed
LO 1.11 Describe primary logic gates
LO 1.12 Discuss various levels of programming languages
LO 1.13 Know various problem solving techniques and computer applications

introduction
A computer is an electronic machine that takes input from the user, processes the given input and generates
output in the form of useful information. A computer accepts input in different forms such as data, programs
and user reply. Data refer to the raw details that need to be processed to generate some useful information.
Programs refer to the set of instructions that can be executed by the computer in sequential or non-
sequential manner. User reply is the input provided by the user in response to a question asked by the
computer.
A computer includes various devices that function as an integrated system to perform several tasks
described above (Fig. 1.1). These devices are:
Central Processing Unit (CPU)
It is the processor of the computer that is responsible for controlling and executing instructions in the computer.
It is considered as the most significant component of the computer.
2 Programming for Problem Solving

Monitor
It is a screen, which displays information in visual form, after receiving the video signals from the computer.
Keyboard and Mouse
These are the devices, which are used by the computer, for receiving input from the user.

Fig. 1.1 The components of computer

Computers store and process numbers, letters and words that are often referred to as data.
l How do we communicate data to computers?
l How do the computers store and process data?
Since the computers cannot understand the Arabic numerals or the English alphabets, we should use
some ‘codes’ that can be easily understood by them.
In all modern computers, storage and processing units are made of a set of silicon chips, each contain-
ing a large number of transistors. A transistor is a two-state device that can be put ‘off’ and ‘on’ by passing
an electric current through it. Since the transistors are sensitive to currents and act like switches, we can
communicate with the computers using electric signals, which are represented as a series of ‘pulse’ and
‘no-pulse’ conditions. For the sake of convenience and ease of use, a pulse is represented by the code ‘1’
and a no-pulse by the code ‘0’. They are called bits, an abbreviation of ‘binary digits’. A series of 1s and
0s are used to represent a number or a character and thus they provide a way for humans and computers
to communicate with one another. This idea was suggested by John Von Neumann in 1946. The numbers
represented by binary digits are known as binary numbers. Computers not only store numbers but also
perform operations on them in binary form.
In this chapter, we discuss how the numbers are represented using what are known as binary codes, how
computers perform arithmetic operations using the binary representation, how digital circuits known as logic
gates are used to manipulate data, how instructions are designed using what are known as programming
languages and how algorithms and flow charts might help us in developing programs.

generations of computers
The history of computer development is often discussed in terms of different LO 1.1
generation of computers, as listed below. Identify the various
l First generation computers generations
l Second generation computers of computers
l Third generation computers
l Fourth generation computers
l Fifth generation computers
Introduction to Computer and Programming 3

These computers used the vacuum tubes


technology (Fig. 1.2) for calculation as well as
for storage and control purposes. Therefore,
these computers were also known as vacuum
tubes or thermionic valves based machines.
Some examples of first generation computers
are ENIAC, EDVAC, EDSAC and UNIVAC.
Advantages
l Fastest computing devices of their time.
l Able to execute complex mathematical
problems in an efficient manner.
Disadvantages
l These computers were not very easy to
program being machine dependent.
l They were not very flexible in running
different types of applications as designed
for special purposes.
l The use of vacuum tube technology made
these computers very large and bulky and
also required to be placed in cool places.
l They could execute only one program at a
time and hence, were not very productive.
l They generated huge amount of heat and
hence were prone to hardware faults.
Fig. 1.2 A vacuum tube

These computers use transistors in place of vacuum tubes in building


the basic logic circuits. A transistor is a semiconductor device that is
used to increase the power of the incoming signals by preserving the
shape of the original signal (Fig. 1.3).
Some examples of second generation computers are PDP-8, IBM
1401 and IBM 7090.
Advantages
l Fastest computing devices of their time.
l Easy to program because of the use of assembly language.
l Small and light weight computing devices.
l Required very less power in carrying out operations.
Disadvantages
l Input and output media for these computers were not improved
to a considerable extent.
l Required to be placed in air-conditioned places. Fig. 1.3 A transistor
4 Programming for Problem Solving

l Very expensive and beyond the reach of home users.


l Being special-purpose computers they could execute only specific applications.

The major characteristic feature of third generation


computer systems was the use of Integrated Circuits
(ICs). ICs are the circuits that combine various electronic
components, such as transistors, resistors, capacitors, etc.
onto a single small silicon chip.
Some examples of third generation computers are NCR
395, B6500, IBM 370, PDP 11 and CDC 7600.
Advantages
l Computational time for these computers was usually
in nanoseconds hence were the fastest computing
devices
l Easily transportable because of their small size.
l They used high-level languages which is machine
independent hence very easy to use. Fig. 1.4 An integrated circuit
l Easily installed and required less space.
l Being able to execute any type of application (business and scientific) these were considered as
general-purpose computers.
Disadvantages
l Very less storage capacity.
l Degraded performance while executing complex computations because of the small storage capacity.
l Very expensive.

The progress in LSI and VLSI technologies led to the development of microprocessor, which became the
major characteristic feature of the fourth generation
computers. The LSI and VLSI technology allowed
thousands of transistors to be fitted onto one small silicon
chip.
A microprocessor incorporates various components
of a computer—such as CPU, memory and Input/Output
(I/O) controls—onto a single chip. Some popular later
microprocessors include Intel 386, Intel 486 and Pentium.
Some of the examples of fourth generation computers
are IBM PC, IBM PC/AT, Apple and CRAY-1.
Advantages
l LSI and VLSI technologies made them small,
cheap, compact and powerful.
l high storage capacity
l highly reliable and required very less maintenance. Fig. 1.5 The Intel P4004 microprocessor chip
Introduction to Computer and Programming 5

l provided a user-friendly environment with the development of GUIs and interactive I/O devices.
l programs written on these computers were highly portable because of the use of high-level languages.
l very versatile and suitable for every type of applications.
l required very less power to operate.
Disadvantages
l the soldering of LSI and VLSI chips on the wiring board was complicated
l still dependent on the instructions given by the programmer.

Fifth generation computers are based on the Ultra Large Scale Integration (ULSI) technology that allows
almost ten million electronic components to be fabricated on one small chip.
Advantages
l faster, cheaper and most efficient computers till date.
l They are able to execute a large number of applications at the same time and that too at a very high
speed.
l The use of ULSI technology helps in decreasing the size of these computers to a large extent.
l very comfortable to use because of the several additional multimedia features.
l versatile for communications and resource sharing.
Disadvantage
They are not provided with an intelligent program that could guide them in performing different operations.
Figure 1.6 shows a tree of computer family that illustrates the area-wise developments during the last
four decades and their contributions to the various generations of computers.

classification of computers
Computers can be classified into several categories depending on their LO 1.2
computing ability and processing speed. These include Classify computers on
l Microcomputer the basis of different
l Minicomputer criteria
l Mainframe computers
l Supercomputers
Microcomputers
A microcomputer is defined as a computer that has a microprocessor as its CPU and can perform the
following basic operations:
l Inputting — entering data and instructions into the microcomputer system.
l Storing — saving data and instructions in the memory of the microcomputer system, so that they can
be use whenever required.
l Processing — performing arithmetic or logical operations on data, where data, such as addition,
subtraction, multiplication and division.
l Outputting — It provides the results to the user, which could be in the form of visual display and/or
printed reports.
l Controlling — It helps in directing the sequence and manner in which all the above operations are
performed.
Minicomputers
A minicomputer is a medium-sized computer that is more powerful than a microcomputer. It is usually
designed to serve multiple users simultaneously, hence called a multiterminal, time-sharing system.
6 Programming for Problem Solving

Fig. 1.6 Tree of computer family


Introduction to Computer and Programming 7

Minicomputers are popular among research and business organizations today. They are more expensive
than microcomputers.
Mainframe Computers
Mainframe computers help in handling the information processing of various organizations like banks,
insurance companies, hospitals and railways. Mainframe computers are placed on a central location and
are connected to several user terminals, which can act as access stations and may be located in the same
building. Mainframe computers are larger and expensive in comparison to the workstations.
Supercomputers
In supercomputers, multiprocessing and parallel processing technologies are used to promptly solve
complex problems. Here, the multiprocessor can enable the user to divide a complex problem into smaller
problems. A supercomputer also supports multiprogramming where multiple users can access the computer
simultaneously. Presently, some of the popular manufacturers of supercomputers are IBM, Silicon Graphics,
Fujitsu, and Intel.

Basic anatomy of a computer system


A computer system comprises hardware and software components. Hardware refers to the physical
parts of the computer system and software is the set of instructions or programs that are necessary for the
functioning of a computer to perform certain tasks. Hardware includes the following components:
l Input devices — They are used for accepting the data on which the operations are to be performed.
The examples of input devices are keyboard, mouse and track ball.

Magnetic Magnetic
Tape Disk

EXTERNAL STORAGE UNITS

Input Input Memory Output Output


Media Unit Unit Unit Media

Arithmetic
Unit

Control
Unit

CPU
Data and results flow
Control Instructions to units
Instructions to control unit
Fig. 1.7 Interaction among hardware components
8 Programming for Problem Solving

l Processor — Also known as CPU, it is used to perform the calculations and information processing
on the data that is entered through the input device.
l Output devices — They are used for providing the output of a program that is obtained after
performing the operations specified in a program. The examples of output devices are monitor and
printer.
l Memory — It is used for storing the input data as well as the output of a program that is obtained
after performing the operations specified in a program. Memory can be primary memory as well as
secondary memory. Primary memory includes Random Access Memory (RAM) and secondary
memory includes hard disks and floppy disks.
Software supports the functioning of a computer system internally and cannot be seen. It is stored on
secondary memory and can be an application software as well as system software. The application
software is used to perform a specific task according to requirements and the system software (operating
system and networking system) is mandatory for running application software.

input DeVices
LO 1.3
Input devices are electromechanical devices that are used to provide data
Describe the computer
to a computer for storing and further processing, if necessary. Depending
system
upon the type or method of input, the input device may belong to one of the
following categories:

Keyboard is used to type data and text and execute commands. A standard keyboard, as shown in Fig. 1.8,
consists of the following groups of keys:

Fig. 1.8 The presently used keyboard


Alphanumeric Keys include the number keys and alphabet keys arranged in QWERTY layout.
Function Keys help perform specific tasks, such as searching a file or refreshing a web page.
Central Keys include arrow keys (for moving the cursor) and modifier keys such as SHIFT, ALT and CTRL
(for modifying the input).
Introduction to Computer and Programming 9

Numeric Keypad looks like a calculator’s keypad with its 10 digits and mathematical operators.
Special Purpose Keys The special purpose keys help perform a certain kind of operation, like exiting a
program (Escape) or deleting some characters (Delete) in a document, etc.

Mouse is a small hand-held pointing device that basically controls the two-dimensional movement of the
cursor on the displayed screen. It is an important part of the Graphical User Interface (GUI) based Operating
Systems (OS) as it helps in selecting a portion of the screen and copying and pasting the text.
The mouse, on moving, also moves the pointer appearing on the display device (Fig. 1.9).
Wheel
Right Button
Left Button

Fig. 1.9 A mechanical mouse

Scanning devices are the input devices that can electronically


capture text and images, and convert them into computer readable
form (Fig. 1.10).
There are the following types of scanners that can be used to
produce digitized images:
l Flatbed scanner — It contains a scanner head that moves
across a page from top to bottom to read the page and
converts the image or text available on the page in digital
form. The flatbed scanner is used to scan graphics, oversized
documents, and pages from books.
l Drum scanner — In this type of scanner, a fixed scanner
head is used and the image to be scanned is moved across Fig. 1.10 A Scanner
the head. The drum scanners are used for scanning prepress
materials.
l Slide scanner — It is a scanner that can scan photographic slides directly to produce files
understandable by the computer.
l Handheld scanner — It is a scanner that is moved by the end user across the page to be scanned.
This type of scanner is inexpensive and small in size.

processor
The CPU consists of Control Unit (CU) and ALU. CU stores the instruction set, which specifies the
operations to be performed by the computer. CU transfers the data and the instructions to the ALU for
10 Programming for Problem Solving

an arithmetic operation. ALU performs arithmetical or logical operations on the data received. The CPU
registers store the data to be processed by the CPU and the processed data also. Apart from CU and ALU,
CPU seeks help from the following hardware devices to process the data:
Motherboard
It refers to a device used for connecting the CPU with the input and output devices. The components on the
motherboard are connected to all parts of a computer and are kept insulated from each other. Some of
the components of a motherboard are:
l Buses: Electrical pathways that transfer data and instructions among different parts of the computer.
For example, the data bus is an electrical pathway that transfers data among the microprocessor,
memory and input/output devices connected to the computer.
l System clock: It is a clock used for synchronizing the activities performed by the computer. The
electrical signals that are passed inside a computer are timed, based on the tick of the clock.
l Microprocessor: CPU component that performs the processing and controls the activities performed
by the different parts of the computer.
l ROM: Chip that contains the permanent memory of the computer that stores information, which cannot
be modified by the end user.
RAM
It refers to primary memory of a computer that stores information and programs, until the computer is used.
RAM is available as a chip that can be connected to the RAM slots in the motherboard.
Video Card/Sound Card
The video card is an interface between the monitor and the CPU. Video cards also include their own RAM
and microprocessors that are used for speeding up the processing and display of a graphic. A sound card is
a circuit board placed on the motherboard and is used to enhance the sound capabilities of a computer.

output DeVices
The main task of an output device is to convert the machine-readable information into human-readable form
which may be in the form of text, graphics, audio or video.

A monitor produces visual displays generated by the computer. The monitor is connected to the video card
placed on the expansion slot of the motherboard.

Fig. 1.11 A CRT monitor and the internal components of a CRT


Introduction to Computer and Programming 11

The monitors can be classified as cathode ray tube (CRT) monitors or liquid crystal display (LCD)
monitors. The CRT monitors are large, occupy more space in the computer, whereas LCD monitors are thin,
light weighted, and occupy lesser space. Both the monitors are available as monochrome, gray scale and
color models.
A monitor can be characterized by its monitor size and resolution. The monitor size is the length of the
screen that is measured diagonally. The resolution of the screen is expressed as the number of picture
elements or pixels of the screen. The resolution of the monitor is also called the dot pitch. The monitor with a
higher resolution produces a clearer image.

The printer is an output device that transfers the text displayed on the screen, onto paper sheets that can
be used by the end user. Printers can be classified based on the technology they use to print the text and
images:
l Dot matrix printers — Dot matrix printers are impact printers that use perforated sheet to print the
text. Dot matrix printers are used to produce multiple copies of a print out.
l Inkjet printers — Inkjet printers are slower than dot matrix printers and are used to generate high
quality photographic prints.
l Laser printers — The laser printer may or may not be connected to a computer, to generate an
output. These printers consist of a microprocessor, ROM and RAM, which can be used to store the
textual information.

These systems record the simple messages in human speech form and then combine all these simple
messages to form a single message. The voice response system is of two types—one uses a reproduction
of human voice and other sounds, and the other uses speech synthesis.
The basic application of a voice output system is in Interactive Voice Response (IVR) systems, which are
used by the customer care or customer support departments of an organization, such as telecommunication
companies, etc.

A projector is a device that is connected to a


computer or a video device for projecting an
image from the computer or video device onto
the big white screen. The images projected
by a projector are larger in size as compared
to the original images. A projector consists of
an optic system, a light source and displays,
which contain the original images. Projectors
were initially used for showing films but now
they are used on a large scale for displaying
presentations in business organizations and for
viewing movies at home. Fig. 1.12 A portable projector
12 Programming for Problem Solving

memory management
The memory unit of a computer is used to store data, instructions for processing data, intermediate results
of processing and the final processed information. The memory units of a computer are classified as primary
and secondary memory. Computers also use a third type of storage location known as the internal process
memory. This memory is placed either inside the CPU or near the CPU (connected through special fast
bus).

Fig. 1.13 Memory unit categories of computer

The primary memory is available in the computer as a built-in unit of the computer. The primary memory is
represented as a set of locations with each location occupying 8 bits. Each bit in the memory is identified by
a unique address. The data is stored in the machine-understandable binary form in these memory locations.
The commonly used primary memories are as follows:
l ROM — ROM represents Read Only Memory that stores data and instructions, even when the
computer is turned off. It is the permanent memory of the computer where the contents cannot be
modified by an end user. ROM is a chip that is inserted into the motherboard. It is generally used to
store the Basic Input/Output system (BIOS), which performs the Power On Self Test (POST).
l RAM — RAM is the read/write memory unit in which the information is retained only as long as there
is a regular power supply. When the power supply is interrupted or switched off, the information stored
in the RAM is lost. RAM is volatile memory that temporarily stores data and applications as long as
they are in use. When the use of data or the application is over, the content in RAM is erased.
l Cache memory — Cache memory is used to store the data and the related application that was last
processed by the CPU. When the processor performs processing, it first searches the cache memory
and then the RAM, for an instruction. The cache memory can be either soldered into the motherboard
or is available as a part of RAM.
Introduction to Computer and Programming 13

Secondary memory represents the external storage devices that are connected to the computer. They
provide a non-volatile memory source used to store information that is not in use currently. A storage
device is either located in the CPU casing of the computer or is connected externally to the computer. The
secondary storage devices can be classified as:
l Magnetic storage device — The magnetic storage devices store information that can be read,
erased and rewritten a number of times. These include floppy disk, hard disk and magnetic tapes.
l Optical storage device — The optical storage devices are secondary storage devices that use laser
beams to read the stored data. These include CD-ROM, rewritable compact disk (CD-RW), digital
video disks with read only memory (DVD-ROM), etc.
l Magneto-optical storage device — The magneto-optical devices are generally used to store
information, such as large programs, files and back-up data. The end user can modify the information
stored in magneto-optical storage devices multiple times. These devices provide higher storage
capacity as they use laser beams and magnets for reading and writing data to the device.

types of computer software


A computer program is basically a set of logical instructions, written in a LO 1.4
computer programming language that tells the computer how to accomplish Classify various computer
a task. The software is therefore an essential interface between the hardware software
and the user (Fig. 1.14).
A computer software performs two distinctive tasks. The first task is to control and coordinate the
hardware components and manage their performances and the second one is to enable the users to
accomplish their required tasks. The software that is used to achieve the first task is known as the system
software and the software that is used to achieve the second task is known as the application software.

Fig. 1.14 Layers of software and their interactions

System software consists of many different programs that manage and support different tasks. Depending
upon the task performed, the system software can be classified into two major groups (Fig. 1.15):
l System management programs used for managing both the hardware and software systems. They
include:
∑ Operating system
14 Programming for Problem Solving

∑ Utility programs
∑ Device drivers
l System development programs are used for developing and executing application software. These
are:
∑ Language translators
∑ Linkers
∑ Debuggers
∑ Editors

Fig. 1.15 Major categories of computer software

Application software includes a variety of programs that are designed to meet the information processing
needs of end users. They can be broadly classified into two groups:
l Standard application programs that are designed for performing common application jobs. Examples
include:
∑ Word processor
∑ Spreadsheet
∑ Database Manager
∑ Desktop Publisher
∑ Web Browser
l Unique application programs that are developed by the users themselves to support their specific
needs. Examples include:
∑ Managing the inventory of a store
∑ Preparing pay-bills of employees in an organization
∑ Reserving seats in trains or airlines

oVerView of operating system


An operating system (OS) is a software that makes the computer hardware LO 1.5
to work. While the hardware provides ‘raw computer power’, the OS is Discuss various operating
responsible for making the computer power useful for the users. OS is the systems
main component of system software and therefore must be loaded and
activated before we can accomplish any other task. The main functions
include:
l Operates CPU of the computer.
l Controls input/output devices that provide the interface between the user and the computer.
Introduction to Computer and Programming 15

Fig. 1.16 The roles of an operating system

l Handles the working of application programs with the hardware and other software systems.
l Manages the storage and retrieval of information using storage devices such as disks.
Based on their capabilities and the types of applications supported, the operating systems can be divided
into the following six major categories:
l Batch operating system — This is the earliest operating system, where only one program is allowed
to run at one time. We cannot modify any data used by the program while it is being run. If an error
is encountered, it means starting the program from scratch all over again. A popular batch operating
system is MS DOS.
l Interactive operating system — This operating system comes after the batch operating system,
where also only one program can run at one time. However, here, modification and entry of data
are allowed while the program is running. An example of an interactive operating system is Multics
(Multiplexed Information and Computing Service).
l Multiuser operating system — A multiuser operating system allows more than one user to use a
computer system either at the same time or at different times. Examples of multiuser operating
systems include Linux and Windows 2000.
l Multi-tasking operating system — A multi-tasking operating system allows more than one program
to run at the same time. Examples of multi-tasking operating systems include Unix and Windows 2000.
l Multithreading operating system — A multithreading operating system allows the running of
different parts of a program at the same time. Examples of multithreading operating system include
UNIX and Linux.
l Real-time operating systems — These operating systems are specially designed and developed for
handling real-time applications or embedded applications. Example include MTOS, Lynx, RTX
l Multiprocessor operating systems — The multiprocessor operating system allows the use of
multiple CPUs in a computer system for executing multiple processes at the same time. Example
include Linux, Unix, Windows 7.
l Embedded operating systems — The embedded operating system is installed on an embedded
computer system, which is primarily used for performing computational tasks in electronic devices.
Example include Palm OS, Windows CE

MS DOS or Microsoft Disk Operating System, which is marketed by Microsoft Corporation and is one of the
most commonly used members of the DOS family of operating systems. MS DOS is a command line user
interface, which was first introduced in 1981 for IBM computers. Although MS DOS, nowadays, is not used
as a stand-alone product, but it comes as an integrated product with the various versions of Windows.
16 Programming for Problem Solving

In MS DOS, unlike Graphical User Interface (GUI)-based operating systems, there is a command line
interface, which is known as MS DOS prompt. Here, we need to type the various commands to perform
the operations in MS DOS operating system. The MS DOS commands can be broadly categorized into the
following three classes:
l Environment command — These commands usually provide information on or affects operating
system environment. Some of these commands are:
∑ CLS: It allows the user to clear the complete content of the screen leaving only the MS-DOS
prompt.
∑ TIME: It allows the user to view and edit the time of the computer.
∑ DATE: It allows the user to view the current date as well as change the date to an alternate date.
∑ VER: It allows us to view the version of the MS-DOS operating system.
l File manipulation command — These commands help in manipulating files, such as copying a file or
deleting a file. Some of these commands include:
∑ COPY: It allows the user to copy one or more files from one specified location to an alternate
location.
∑ DEL: It helps in deleting a file from the computer.
∑ TYPE: It allows the user to view the contents of a file in the command prompt.
∑ DIR: It allows the user to view the files available in the current and/or parent directories.
l Utilities — These are special commands that perform various useful functions, such as formatting a
diskette or invoking the text editor in the command prompt. Some of these commands include:
∑ FORMAT: It allows the user to erase all the content from a computer diskette or a fixed drive.
∑ EDIT: It allows the user to view a computer file in the command prompt, create and modify the
computer files.

Windows Architecture
The architecture of Windows operating system comprises a modular structure that is compatible with a
variety of hardware platforms. Figure 1.17 shows the architecture of Windows 2000; the later releases of
Windows operating systems are based on similar architecture.
At a high level, the architecture is divided into three layers, viz.
l User mode: Comprises application and I/O specific software components
l Kernel mode: Has complete access to system resources and hardware
l Hardware: Comprises underlying hardware platform
User Mode
The various subsystems in the user mode are divided into the following two categories:
l Environment subsystems: Comprise subsystems that run applications written for other operating
systems. These subsystems cannot directly request hardware access; instead such requests are
processed by virtual memory manager present in the kernel mode. The three main environment
subsystems include Win32, OS/2 and POSIX. Each of these subsystems possess dynamic link
libraries for converting user application calls to Windows calls.
l Integral subsystems: Takes care of the operating system specific functions on behalf of the
environment subsystems. The various integral subsystems include workstation service, server service
and security.
Introduction to Computer and Programming 17

Fig. 1.17 The architecture of Windows 2000

Kernel Mode
The kernel mode comprises various components with each component managing specific system function.
Each of the components is independent and can be removed, upgraded or replaced without rewriting the
entire system. The various kernel-mode components include:
l Executive: Comprises the core operating system services including memory management, process
management, security, I/O, inter process communication etc.
l Kernel: Comprises the core components that help in performing fundamental operating system
operations including thread scheduling, exception handling, interrupt handling, multiprocessor
synchronization, etc.
l HAL: Acts as a bridge between generic hardware communications and those specific to the underlying
hardware platform. It helps in presenting a consistent view of system bus, DMA, interrupt controllers,
timers, etc. to the kernel.
l I/O manager: Handles requests for accessing I/O devices by interacting with the relevant device
drivers.
l Security reference monitor: Performs access validation and audit checks for Windows objects
including files, processes, I/O devices, etc.
l Virtual Memory Manager: Performs virtual memory management by mapping virtual addresses to
actual physical pages in computer’s memory.
l Process Manager: Creates and deletes objects and threads throughout the life cycle of a process.
l PnP manager: Supports plug-and-play devices by determining the correct driver for a device and
further loading the driver.
18 Programming for Problem Solving

l Power manager: Performs power management for the various devices. It also optimizes power
utilization by putting the devices to sleep that are not in use.
l GDI: Stands for Graphics Device Interface and is responsible for representing graphical objects in
Windows environment. It also transfers the graphical objects to the output devices such as printer and
monitor.
l Object manager: Manages Windows Executive objects and abstract data types that represent the
various resources such as processes, threads, etc.

UNIX operating system was developed by a group of AT&T employees at Bell Labs in the year 1969. UNIX
is primarily designed to allow multiple users access the computer at the same time and share resources.
The UNIX operating system is written in C language. The significant properties of UNIX include:
l Multi-user capability
l Multi-tasking capability
l Portability
l Flexibility
l Security
Architecture of UNIX
UNIX has a hierarchical architecture consisting of several layers, where each layer provides a unique
function as well as maintains interaction with its lower layers. The layers of the UNIX operating system are:
l Kernel
l Service
l Shell
l User applications
Figure 1.18 shows the various layers of the UNIX operating system.
l Kernel Kernel is the core of the UNIX operating system and it gets loaded into memory whenever
we switch on the computer. Three components of kernel are:
∑ Scheduler — It allows scheduling the processing of various jobs.
∑ Device driver — It helps in controlling the Input/Output devices attached to the computer.
∑ I/O buffer — It controls the I/O operations in the computer.
Various functions performed by the kernel are:
∑ Initiating and executing different programs at the same time
∑ Allocating memory to various user and system processes
∑ Monitoring the files that reside on the disk
∑ Sending and receiving information to and from the network
l Service In the service layer, requests are received from the shell and they are then transformed
into commands to the kernel. The service layer, which is also known as the resident module layer, is
indistinguishable from the kernel and consists of a collection of programs providing various services,
which include:
∑ Providing access to various I/O devices, such as keyboard and monitor
∑ Providing access to storage devices, such as disk drives
∑ Controlling different file manipulation activities, such as reading from a file and writing to a file
Introduction to Computer and Programming 19

User Applications

Shell

Service Layer

Kernel

Hardware

(Scheduler, Device Driver, I/O Buffers)

(Process Management, Memory Management, I/O


services, and File System

(Library Routines)

Fig. 1.18 The layers of UNIX operating system

l Shell The third layer in the UNIX architecture is the shell, which acts as an interface between a user
and the computer for accepting the requests and executing programs. The shell is also known as the
command interpreter that helps in controlling the interaction with the UNIX operating system. The
primary function of the shell is to read the data and instructions from the terminal, and then execute
commands and finally display the output on the monitor. The shell is also termed as the utility layer as
it contains various library routines for executing routine tasks. The various shells that are found in the
UNIX operating system are:
∑ Bourne shell
∑ C shell
∑ Korn shell
∑ Restricted shell
l User applications The last layer in the UNIX architecture is the user applications, which are used to
perform several tasks and communicating with other users of UNIX. Some of the important examples
of user applications include text processing, software development, database management and
electronic communication.

ms worD
MS Word is application software that can be used to create, edit, save LO 1.6
and print personal as well as professional documents in a very simple and Discuss Microsoft software
efficient manner. MS Word is an important tool of the MS office suite that is
mainly designed for word processing. Other word processing applications
available are, Open Office Writer and Google Docs.
20 Programming for Problem Solving

For working in MS Word, we need to install MS Office in a computer system. After installing MS Office, we
can start MS Word by using any of the following two ways:
l Start menu
l Run command
We can start MS Word by performing the following steps using the Start menu:
1. Select Start Æ All Programs Æ Microsoft Office,
2. Select the Microsoft Office Word 2007 option to display the Graphical User Interface (GUI) of MS
Word, as shown in Fig. 1.19.

Fig. 1.19 The Document1 – Microsoft Word window

Using Run command We can also start MS Word by performing the following steps using the Run
command:
1. Select Start Æ All Programs Æ Accessories Æ Run to display the Run dialog box.
2. Type winword in the Open text box and click OK to display the Document1 – Microsoft Word window.

The following are the key operations that we can perform in MS Word:
l Creating a document
l Saving a document
l Editing a document
l Formatting a document
l Printing a document
Introduction to Computer and Programming 21

ms eXcel system
MS Excel is an application program that allows us to create spreadsheets, which are represented in the form
of a table containing rows and columns. The horizontal sequence in which the data is stored is referred to as
a row. The vertical sequence in which the data is stored is referred to as a column. In a spreadsheet, a row
is identified by a row header and a column is identified by a column header. Each value in a spreadsheet
is stored in a cell, which is the intersection of rows and columns. A cell can contain either numeric value
or a character string. We can also specify the contents of a cell using formulas. In a spreadsheet, we can
perform various mathematical operations using formulas, such as addition, subtraction, multiplication,
division, average, percentage, etc.
MS Excel also allows us to represent the complex data pictorially in the form of graphs. These are
generally used to represent the information with the help of images, colours, etc., so that their presentation
is simple and more meaningful. Some of the graphs available in spreadsheet are bar graphs, line graphs,
3-D graphs, area graphs, etc.

For working with MS Excel, we first need to install MS Office in our computer system. After installing MS
Office, we can start MS Excel using any of the following two ways:
l Start menu
l Run command
Using Start menu We can start MS Excel by performing the following steps using the Start menu:
1. Select Start Æ All Programs Æ Microsoft Office, as shown in Fig. 1.20.
2. Select the Microsoft Office Excel 2007 option to display the GUI of MS Excel,

Fig. 1.20 The Microsoft Excel—Book1 window


22 Programming for Problem Solving

Figure 1.20 shows the initial workbook of MS Excel, which in turn contains worksheets. Each worksheet
contains rows and columns where we can enter data.

Using Run command We can also start MS Excel by performing the following steps using the Run
command:
1. Select Start Æ All Programs Æ Accessories Æ Run to display the Run dialog box.
2. Type excel in the Open text box and click OK to display the Microsoft Excel – Book1 window.

Worksheet is the actual working area consisting of rows and columns. The worksheets are also known as
the spreadsheets. A workbook in MS Excel is a combination of several worksheets. Each workbook of MS
Excel contains three worksheets by default. The key operations that are performed in MS Excel include:
l Creating a worksheet
l Saving a worksheet
l Modifying a worksheet
l Renaming a worksheet
l Deleting a worksheet
l Moving a worksheet
l Editing a worksheet

ms powerpoint system
MS PowerPoint is a software application included in the MS Office package that allows us to create
presentations. PowerPoint provides a GUI with the help of which we can create attractive presentations
quickly and easily. The presentation may include slides, handouts, notes, outlines, graphics and animations.
A slide in PowerPoint is a combination of images, text, graphics, charts, etc., that is used to convey some
meaning information. The presentations in MS PowerPoint are usually saved with the extension .ppt.
The interface of MS PowerPoint is similar to the other interfaces of MS Office applications. PowerPoint
presentations are commonly used in business, schools, colleges, training programmes, etc.

For working in MS PowerPoint, we need to first install the MS Office package in our computer system. After
installing MS Office, we can start MS PowerPoint using any of the following two ways:
l Start menu
l Run command
Using Start menu We can start MS PowerPoint by performing the following steps using the Start menu:
1. Select Start Æ All Programs Æ Microsoft Office,
2. Select the Microsoft Office PowerPoint 2007 option to display the GUI of MS PowerPoint, as shown in
Fig. 1.21.
Using Run command We can also start MS PowerPoint by performing the following steps using the Run
command:
1. Select Start Æ All Programs Æ Accessories Æ Run to display the Run dialog box.
2. Type powerpnt in the Open text box and click OK to display the Microsoft PowerPoint –
[Presentation1] window.
Introduction to Computer and Programming 23

Fig. 1.21 The Microsoft PowerPoint—[Presentation1] Window

The following are the key operations that can be performed in MS PowerPoint:
l Creating a new presentation
l Designing the presentation
l Saving a new presentation
l Adding slides to the presentation
l Printing the presentation

networking concepts
Computer network is a system of interconnected computers that enable LO 1.7
the computers to communicate with each other and share their resources, Know various networking
data and applications. The physical location of each computer is tailored to concepts and protocols
personal and organisational needs. A network may include only personal
computers or a mix of PCs, minis and mainframes spanning a particular
geographical area. Computer networks that are commonly used today may be classified as follows:
l Based on geographical area:
∑ Local Area Networks (LANs)
∑ Wide Area Networks (WANs)
∑ Metropolitan Area Networks (MANs)
∑ International Network (Internet)
∑ Intranet
24 Programming for Problem Solving

l Based on how computer nodes are used:


∑ Client Server Networks (CSNs)
∑ Peer-to-peer Networks (PPNs)
∑ Value-added Networks (VANs)

LAN is a group of computers, as shown in Fig. 1.22, that are connected in a small area such as building,
home, etc. Through this type of network, users can easily communicate with each other by sending and
receiving messages. LAN is generally used for connecting two or more personal computers through some
medium such as twisted pair, coaxial cable, etc. Though the number of computers connected in a LAN is
limited, the data is transferred at an extremely faster rate.

Fig. 1.22 A LAN

WAN is a group of computers that are connected in a large area such as continent, country, etc. WAN
is generally used for connecting two or more LANs through some medium such as leased telephone
lines, microwaves, etc. In WAN, data is transferred at slow rate. A typical WAN network is shown in Fig. 1.23.

MAN is a network of computers that covers a large area like a city. The size of the MAN generally lies
between that of LAN and WAN, typically covering a distance of 5 km to 50 km. The geographical area
covered by MAN is comparatively larger than LAN but smaller than WAN. MAN is generally owned by
private organisations. MAN is generally connected with the help of optical fibres, copper wires etc. One of
the most common example of MAN is cable television network within a city as shown in Fig. 1.24. A network
device known as router is used to connect the LANs together. The router directs the information packets to
the desired destination.
Introduction to Computer and Programming 25

Fig. 1.23 A WAN system

Fig. 1.24 A typical MAN system

network topologies
Network topology refers to the arrangement of computers connected in a network through some physical
medium such as cable, optical fibre etc. Topology generally determines the shape of the network and the
communication path between the various computers (nodes) of the network. The various types of network
topologies are as follows:
l Hierarchical topology
l Bus topology
26 Programming for Problem Solving

l Star topology
l Ring topology
l Mesh topology
l Hybrid topology

The hierarchical topology is also known as tree topology, which is divided into different levels connected
with the help of twisted pair, coaxial cable or fibre optics. Figure 1.25 shows the arrangement of computers
in hierarchical topology.

Fig. 1.25 The hierarchical topology

Advantages of hierarchical topology are:


l The hierarchical topology is generally supported by most hardware and software.
l In the hierarchical topology, data is received by all the nodes efficiently because of point-to-point link.
The following are the disadvantages of hierarchical topology:
l In the hierarchical topology, when the root node fails, the whole network crashes.
l The hierarchical topology is difficult to configure.

In the linear bus topology, all the nodes are connected to the single backbone or bus with some medium
such as twisted pair, coaxial cable, etc. Figure 1.26 shows the arrangement of computers in the linear bus
topology.
Advantages of linear bus topology are:
l The linear bus topology usually requires less cabling.
l The linear bus topology is relatively simple to configure and install.
l In the linear bus topology, the failure of one computer does not affect the other computers in the
network.
Introduction to Computer and Programming 27

The following are the disadvantages of linear bus topology:


l In the linear bus topology, the failure of the backbone cable results in the breakdown of entire network.
l Addition of computers in the linear bus topology results in the performance degradation of the network.
l The bus topology is difficult to reconstruct in case of faults.

Fig. 1.26 A linear bus topology Fig. 1.27 A star topology

In the star topology, all the nodes are connected to a common device known as hub. Nodes are connected
with the help of twisted pair, coaxial cable or optical fibre. Figure 1.27 shows the arrangement of computers
in star topology.
Advantages of star topology are:
l This topology allows easy error detection and correction.
l In the star topology, the failure of one computer does not affect the other computers in the network.
l Star topology is easy to install.
The following are the disadvantages of star topology:
l In the star topology, the hub failure leads to the overall network crash.
l The star topology requires more amount of cable for connecting the nodes.
l It is expensive due to the cast of hub.

In the ring topology, the nodes are connected in the form of a ring with the help of twisted pair. Each node is
connected directly to the other two nodes in the network. Figure 1.28 shows the arrangement of computers
in the ring topology.
28 Programming for Problem Solving

Fig. 1.28 A ring topology

Advantages of ring topology are:


l Each node has an equal access to other nodes in the network.
l Addition of new nodes does not degrade the performance of the network.
l Ring topology is easy to configure and install.
The following are the disadvantages of ring topology:
l It is relatively expensive to construct the ring topology.
l The failure of one node in the ring topology affects the other nodes in the ring.

In mesh topology, each computer is connected to every other computer in point-to-point mode as shown in
Fig. 1.29. If we have n computers, we must
have n(n – 1)/2 links.
Advantages of mesh topology are:
l Message delivery is more reliable.
l Network congestion is minimum due to
large number of links.
The following are the disadvantages:
l It is very expensive to implement.
l It is very difficult to configure and install.

The hybrid topology is the combination of


multiple topologies, used for constructing a
single large topology. Figure 1.30 shows a
typical arrangement of computers in hybrid
topology. Fig. 1.29 Mesh topology
Introduction to Computer and Programming 29

Fig. 1.30 A hybrid topology


Advantages of hybrid topology are:
l The hybrid topology is more effective as it uses multiple topologies.
l The hybrid topology contains the best and efficient features of the combined topologies from which it is
constructed.
The following are the disadvantages of hybrid topology:
l The hybrid topology is relatively more complex than the other topologies.
l The hybrid topology is difficult to install and configure.

network protocols anD software


In order to share data between computers, it is essential to have appropriate network protocols and
software. With the help of network protocol, computers can easily communicate with each other and can
share data, resources, etc.

Network protocols are the set of rules and regulations that are generally used for communication between
two networks. Using network protocol, the following tasks can be performed:
l Identification of the type of the physical connection used
l Error detection and correction of the improper message
l Initiation and termination of the communication session
l Message formatting
Some of the commonly used network protocols are Hyper Text Transfer protocol (HTTP), Simple Mail
Transfer Protocol (SMTP), File Transfer Protocol (FTP), Transmission Control Protocol/Internet Protocol
(TCP/IP), Telecommunications Network (Telnet), Domain Name System (DNS) etc.
30 Programming for Problem Solving

HTTP
Hyper Text Transfer Protocol (HTTP) is the communication protocol used by the World Wide Web. It acts as
a request-response protocol where the client browser and the Web server interact with each other through
HTTP protocol rules. These rules define how messages are formatted and transmitted and what actions
should the browser and Web server take in response to these messages. For example, when we type a
URL in the address bar of a browser, then an HTTP request is sent to the Web server to fetch the requested
Web page. The Web page details are transmitted to the client browser and rendered on the browser window
through HTML.
In a typical situation, the client browser submits an HTTP request to the server and the server processes
the request and returns an HTTP response to the client. The response contains status information pertaining
to the request as well as the requested content (Figs 1.31–1.32).

Fig. 1.31 HTTP Request Message format Fig. 1.32 HTTP Response Message format
HTTP protocol supports various methods that are used by the client browsers to send request messages
to the server. Some of the common HTTP methods are:
l GET: Gets information from the specified resource
l HEAD: Gets only the HTTP headers
l POST: Posts information to the specified resource
l DELETE: Deletes the specified resource
l OPTIONS: Returns the list of HTTP methods that are supported by the Web server
l TRACE: Returns a diagnostic trace of the actions taken at the server end
The first line in an HTTP response object comprises a status line, which carries the response status code
indicating the outcome of the HTTP request processed by the server. The status code is a 3-digit number
and carries specific meaning, as described below:
l 1xx: Comprises information status messages indicating that the server is still processing the request
l 2xx: Comprises success status messages indicating that the request was received, accepted and
processed by the server
l 3xx: Comprises redirection status messages indicating that further action needs to be taken in order to
process the request
l 4xx: Comprises error status messages indicating error at client side, for example incorrect request
syntax
l 5xx: Comprises error status messages indicating error at server side, for example inability of the
server to process the request
SMTP
Simple Mail Transfer Protocol (SMTP) is an e-mail protocol that is widely used for sending e-mail messages
between mail servers. While SMTP supports capabilities for both sending and receiving e-mail messages,
e-mail systems primarily used SMTP protocol for sending e-mail messages. For receiving, they use other
protocols such as POP3 of IMAP. In Unix-based systems, sendmail is the most widely used SMTP server for
e-mail. In Windows-based systems, Microsoft Exchange comes with an SMTP server and can be configured
to include POP3 support.
Introduction to Computer and Programming 31

FTP
File Transfer Protocol (FTP) is a standard protocol used for sharing files over the Internet. FTP is based
on the client-server architecture and uses Internet’s TCP/IP protocol for file transfer. The users need to
authenticate themselves by specifying user name/password in order to establish a connection with the
FTP server. However, some FTP sites also support anonymous login where users are not required to enter
their credentials. To facilitate secure transfer of user’s credentials and file contents over the Internet, FTP
encrypts the content using cryptographic protocols such as TLS/SSL.
The following steps illustrate how file transfer happens through FTP:
1. The client machine uses Internet to connect to the FTP server’s IP address.
2. User authentication happens by entering relevant user name and password.
3. Once the connection is established, the client machine sends FTP commands to access and transfer
files. Now-a-days, various GUI-based FTP software are available that enable transfer of files through
simple operations, such as drag and drop.
Telnet
Telnet is a protocol that allows users to connect to remote computers over a TCP/IP network, such as
intranet or internet. While HTTP and FTP protocols are used for transferring Web pages and files over the
Internet, the Telnet protocol is used for logging onto a remote computer and performing operations just as a
normal user. The users need to enter their credentials before logging on the remote host machine.
Command-line based telnet access is available in major operating systems such as Windows, Mac OS,
Unix and Linux. Generic format of the telnet command is given below:
Telnet host port
Here,
l telnet: Is the command that establishes telnet connection
l host: Is the address of the host machine
l port: Is the port number on which telnet services are available on the host machine

Decimal system
The decimal system is the most common number system used by human beings. It is a positional number
system that uses 10 as a base to represent different values. Therefore, this number system is also known
as base10 number system. In this system, 10 symbols are available for representing the values. These
symbols include the digits from 0 to 9. The common operations performed in the decimal system are
addition (+), subtraction (–), multiplication (×) and division (/).
The decimal system can be used to represent both the integer as well as floating point values. The
floating point values are generally represented in this system by using a period called decimal point.
The decimal point is used to separate the integer part and the fraction part of the given floating point
number. However, there is no need to use a decimal point for representing integer values. The value of any
number represented in the decimal system can be determined by first multiplying the weight associated with
each digit in the given number with the digit itself and then adding all these values produced as a result of
multiplication operation. The weight associated with any digit depends upon the position of the digit itself in
the given number. The most common method to determine the weight of any digit in any number system is
to raise the base of the number system to a power that initially starts with a 0 and then increases by 1 as we
move from right to left in the given number. To understand this concept, let us consider the following floating
point number represented in the decimal system:
Another random document with
no related content on Scribd:
First Sight of the “Valley of the Mist.”
The Oases of the Libyan desert lie in
depressions several hundred feet deep in the
main plateau. This huge depression had not
previously been reported. (p. 95).

Gazelle Trap. (266) Trap for Quail and Small Birds.


(268)
(Large-size)
These two ingenious traps are used by the people of Farafra Oasis, many of whom are
great hunters.

After some discussion, during which he displayed much learning


in his occult science, it was at length arranged that he should go
through the performance on the following day.
The next morning he arrived with his staff and rosary and came
up the stairs muttering prayers, or incantations, as before.
After he had drunk the usual tea, and approved of the boy that
had been provided, he declared himself ready to start work. He
asked for a charcoal fire in a brazier, some paper and ink. He then
retired to the room that had been cleared for him, and, having closed
the door and shutters, so as to produce an imposing dim religious
light, seated himself in the darkest corner on a black sheep-skin, with
the brazier beside him, and requested to be left alone while he went
through the preliminary ceremonies. The doctor and I accordingly
retired to another room, taking the boy with us.
Soon a faint smell of incense that reached us from next door, the
sound of much muttering and an occasional shout, as the magician
invoked the spirits, told us that he had got to work.
After his dawa had been going on for some ten minutes the
magician called out to us that he was ready, and that we could bring
in the boy. He made him sit down on the sheep-skin cross-legged in
front of him, patted him and told him there was nothing to be afraid
of, if he only did as he was told, and at length soothed him
sufficiently to enable the performance to be continued.
The magician first drew in ink the khatim (seal) on the palm of the
boy’s right hand. He then put a written slip of paper on his forehead,
licking it to make it stick to his skin, and finally, as that did not make it
adhere, slipping the top edge of it under the rim of his cap. He then
proceeded to complete the khatim by putting a large blot of ink in the
centre of the square he had drawn—the whole when completed
having the following appearance:
The magician told the boy to gaze in the pool of ink in his hand
and to fear nothing, and started again with the spells.
He soon got seriously to work, repeating his incantations over and
over again at an extraordinarily rapid rate, swaying himself to and
fro, sometimes dropping his voice to a whisper that was almost
inaudible, then suddenly raising it to a shout as he called upon
Maimun, or some other afrit. At length he worked himself up to such
a pitch that the perspiration fairly streamed from his face. Now and
then he dropped pieces of incense into the earthenware dish that he
used as brazier; once he pulled out a leather pouch and produced a
knife and pieces of stick, from which he cut off shavings to drop into
the fire. Soon the whole room was filled with the sweet sickly smoke
of burning perfumes.
Occasionally he peered through the smoke at the boy to judge
how far he had been affected by his magic. After a time he
apparently concluded that the end of the incantations was close at
hand. He redoubled his efforts, jabbering at such a pace that it was
impossible to catch a single word and working himself up to an
extraordinary pitch of excitement. Then he suddenly dropped his
voice till it became almost inaudible, and followed this up by shouting
out something as loud as he could bawl. He stopped abruptly; leant
back panting against the wall, mopped his streaming face and told
the boy to say “Ataro.”
The boy repeated the word after him. The magician, evidently
considering that his labours were over, then asked the boy to tell us
what he saw in the ink.
The experiment, however, proved a distinct failure. The boy was
unable to see anything, and, though the magician tried again to
reduce him to the clairvoyant state, he was equally unsuccessful on
the second attempt.
On a subsequent occasion, when I met this magician, I induced
him to write out the necessary incantations, etc., required for the
performance of the mandal. The translation of what he wrote on the
paper that he placed on the tahdir’s forehead was as follows:
“We have set forth your propositions, and according to the Koran
we beg our Prophet Mohammed to answer our prayer.”
He commenced the incantations by calling on the spirits he was
invoking thus:
“Toorsh, toorsh, Fiboos, fiboos, Sheshel, sheshel, Koftel, koftel,
Kofelsha.”
The first four names, which are each repeated twice, are those
which are written so as to form the frame of the khatim, the first
being that at the top, the second the one on the left, the third the
bottom one and the fourth that on the right-hand side. The last word,
“Kofelsha,” does not appear in the khatim, and may be some word
used in magic.
The dawa, or invocation proper, ran as follows:
“Descend this day, Oh! Celestial Spirits, so that he here may see
you with his own eyes and talk to you with his own mouth and set
before you that which he desires. Descend quickly, and without
delay, this very minute. I call on you in the name of Solomon, in the
name of Allah the clement and gracious, to obey and to submit
yourselves to my orders for the love of Allah. Zaagra zagiran
zaafiran hafayan nakeb, Zaagra Zagiran Zaafiran hafayan nakeb,
zaagra zagiran zaafiran hafayan nakeb.”
This dawa was repeated over and over again, punctuated
occasionally with a loud shout of “Maimun,” which was presumably
the name of his own familiar spirit.
The last part of the dawa, which it will be seen is a series of words
three times repeated, is untranslatable. It is either the names of
some fresh spirits or, more probably, some magical gibberish
designed to impress the tahdir and spectator.
He told me that if the séance had not been a failure, and he had
been able to get the spirits under his control when summoned, that it
would have been necessary for him to have liberated them
afterwards by means of a second incantation which he called a saraf
(change?), the form of which was as follows:
“In the name of Allah who has sent you, subdued to my orders, I
pray you, Oh! spirits, to go back whence you came. I pray Allah to
preserve you for ever to do good and to fulfil all that is asked of you.”
Later on, while staying at Luxor, I made another attempt to
witness the mandal. This time I was rather more successful.
The dawa, so far as I could see, was practically the same as the
invocation of the magician in Dakhla; but the Sheykh el Afrit made no
attempt to be impressive, and went through the performance in the
most perfunctory manner. The boy appeared to be merely bored,
and anxious only to earn his bakhshish, and to get away again and
play.
When he had finished the incantations, the magician asked the
boy what he saw in the ink. He replied that he saw a broom
sweeping the ground. The magician told him that, when the
sweeping was finished, he was to tell “them” (presumably the spirits)
to pitch a tent.
After a short interval, during which the boy attentively watched the
ink, he said that the tent was pitched. He was then told to command
them to place seven chairs in it. When the boy declared that this had
been done, he was told that they were to summon the seven kings.
Shortly after, the boy declared that the kings had arrived and were
seated on the chairs.
The Sheykh el Afrit then asked me what it was I wanted to know. I
told him I wished the boy to tell me of what I was thinking, and I
pictured to myself a young man of the Tawarek race I had once met
in the desert.
The boy peered into the ink for some time before answering.
Then, in a rather hesitating voice, said that he saw a woman.
I asked if she were veiled. The boy replied that she was. I told him
to describe the veil. He said it was black, and in two parts, one
covering the lower part of her face and the other the upper portion.
This was correct. The man I had seen was wearing the usual
litham, or mask, carried by his race, consisting of a long strip of black
cotton, wrapped twice round his head, the lower strip covering his
face up to the level of his eyes and the upper one concealing his
forehead, a narrow opening being left between the two through
which he could see.
I next asked the boy if he could see the woman’s hair. It was a
long time before he replied to this question. Then, in a very doubtful
tone, as though he felt he were not describing it properly, he said he
could see it sticking up from the top of her head.
This was also correct, as the litham the man had been wearing
did not cover the crown of his head, and consequently his hair was
exposed. It was remarkable, owing to the fact that Moslem women
are even more particular to conceal the top of their heads than to
cover their faces. The crown of their head must not be seen by their
own father, or some say even by the moon.
I then told the boy that his description was perfectly accurate,
except that, as the figure he saw was veiled, he had very naturally
concluded it to be that of a woman instead of a man. I asked him
whether the man carried any weapons, and pictured to myself a
curious dagger he had been wearing, which lay along the under side
of his left forearm, secured to it by a band round his wrist, with the
hilt lying in the palm of his hand.
The boy replied that he carried a sword. This was true, though I
was not thinking of it at the time. I asked him to tell me what he was
doing with it. He said he could see a drawn sword, and the man was
holding it in his left hand. He again seemed doubtful in making this
statement.
The left hand is considered as unclean among Moslems, and
consequently left-handed natives are very rare, so, although his
statement as to his holding a drawn sword in his hand was wrong,
the connection with the left hand, on which the man had been
carrying the sheathed dagger I had had in my mind, was rather
curious, unless he were seeing his image reversed, as he would
have done if he had seen him in a mirror. I asked him whether he
was sure that it was a sword that he saw, and not a dagger, but he
was quite positive on the point, and added that it was an unusually
long one. This would have tallied well with the sword, which was a
long and straight one, much like the ordinary Dervish type from the
Sudan. But I had been thinking of the dagger and not of the sword,
so on this point he was wrong.
At this point in the proceedings the wretched dragoman from the
hotel, who had led me to the magician, shoved in his oar, asked the
boy some stupid question, causing him to look up from the ink to
reply, and the magician declared it would be useless to ask him any
further questions, as the spell had been broken.
This method of clairvoyance, if such it be, has been seen by
several reliable Europeans—Lane, for instance, gives an account of
it in his book on “The Manners and Customs of the Modern
Egyptians”—and there can be no doubt at all that, in some
unexplained manner, correct answers have often been given to the
questions asked of the boy when the possibility of collusion was out
of the question.
The phenomena of thought transference have been considerably
investigated of late years, and many serious scientists believe in the
possibility of communicating ideas in this way, without the medium of
either speech or hearing. Assuming this to be feasible, thought
transference affords a ready means of explaining the phenomena of
the Derb el Mandal in a case like that I have just described.
But the mandal is said to be used with success for other purposes
besides the mere reading of another person’s thoughts. The finding
of hidden treasure, or articles that have been lost, is a very frequent
reason for it being employed, and I have been assured, by natives,
that the results are often satisfactory; but reliable evidence on this
point is certainly desirable.
One of the railway guards in the Nile Valley used to have a great
reputation for doing the mandal. He was once called in to diagnose
the case of the young daughter of a man I knew, and to prescribe
treatment. This, I was told, he did successfully, and the girl
completely recovered. There is nothing, however, remarkable in this,
as most complaints will cure themselves if doctors and other
magicians will only leave them alone. The influence, too, of faith-
healing and suggestion in this case would also have to be
considered.
The railway man used a small mirror instead of a pool of ink. The
boy, who was looking into it, stated subsequently that, after gazing at
it for some time, it appeared to become greatly enlarged, and a room
seemed to be reflected in it. This he was told to order to be swept
and then sprinkled. I have seen a glass of water used instead of a
pool of ink, and believe that a basin of oil is also sometimes
employed. The whole question is an extremely curious one, and
might possibly repay investigations on the ground that it is not magic.
CHAPTER XXVII

NATURAL HISTORY

T HE intense heat and dryness, with the resulting great


evaporation, combined with the almost total absence of rain, and
the cutting action of the sand, when driven by the furious desert
gales, makes the existence of vegetation in the desert almost an
impossibility.
Still here and there a few blades of grass, or even a green bush or
two, are to be met with, though one may travel for several days’
journey in any direction from them before any other growing plants
are to be seen.
The plants that grow in the desert are all especially adapted by
nature to withstand the heat and drought. The stems of the bushes
have a dense outer covering to prevent evaporation. Their leaves
are small and leathery for the same reason. But their chief peculiarity
is perhaps the extraordinary development of their roots, which
stretch for enormous distances in search of water.
Some of the wild plants I collected in Dakhla Oasis were found
growing on very saline ground—in a few cases the soil around them
being white, with the salt lying on the surface. The date palm seems
to have been specially designed by nature to flourish under desert
conditions. A palm will grow in soils containing as much as four per
cent of salt, providing its roots can reach a stratum containing less
than one per cent, and, if it can find a layer with a half per cent of salt
only, it is capable of yielding an abundant crop.
The animals in the oasis are no less interesting than the plants.
The nights in Dakhla—especially at Rashida and Mut—are made
hideous by the dismal howling of the jackals. The dog tribe in the
oasis are probably unusually interesting. I collected a number of
skins, but, when I went off into the desert, was unable to take them
with me, and had to leave them behind in a half-cured state in Mut.
Insects swarm in the hot weather, with the result that, by the time I
returned from my various desert trips, I invariably found that they had
got at my skins to such an extent as to render them worthless to any
museum.
One jackal skin that I managed to bring in in a fair state, and gave
to the Natural History Museum in Kensington, was most kindly
identified for me by Mr. Martin A. C. Hinton as being identical with
the large Egyptian jackal, or “wolf,” canis lupaster. All the jackals of
Dakhla are of an unusually large size, and are locally called wolves. I
was told that they breed freely with the village dogs. In addition to
the jackals, foxes are extremely numerous, some being apparently
identical with the common greyish fox of the Nile Valley.
There are probably some species of the dog tribe in the oasis
which are new. One evening near Mut I happened to be returning to
the town about sunset, and noticed a fox that struck me as being of
an unusual appearance. Shortly after I first saw him, he went to the
far side of a low mound of earth; I was consequently able to
approach him unseen, and managed to get within about ten yards of
him before attracting his attention. He then bolted; but not before I
had had a good view of him.
He was a fairly large fox of a greyish brown colour, and carried a
very fine brush. But his most striking peculiarity was that he was
covered with large black spots, which appeared to be about an inch
and a half in diameter. On questioning the inhabitants, I found that a
spotted fox was occasionally seen in the oasis, but was not
apparently very common. Markings of this nature are, I believe, quite
unknown in any fox, so that this one probably was of unusual
interest. Unfortunately, I was unable to secure a specimen.
In addition to the jackals and foxes, an occasional hyena is said to
appear in the oasis, but none, so far as I heard, were seen while I
was there.
A curious fact in relation to the jackals in Dakhla is that they
appear to be to a great extent vegetarians, living largely upon the
fallen fruit in the plantations—a fact which recalls the story of the fox
and the grapes.
Gazelles used to be fairly numerous in the scrub-covered areas in
and around the oases, but I invariably found them extremely shy and
difficult to approach. Once, in the distance, I caught sight of a pair
that looked interesting. One of them had an extremely pale coat, and
was perhaps a rim (Loder’s gazelle); but the other was of a deep
reddish—almost chestnut—colour that, from a distance, looked
unlike any known variety. The usual gazelle found in these parts is
the common Dorcas; but these two looked entirely different. The
natives do not seem to distinguish between the various varieties, all
of which bear a strong resemblance to each other, classing them
altogether as “gazelle.”
Scorpions swarm in the older buildings of the town, and the
natives get frequently stung, sometimes, I was told, with fatal effect.
The leaves of a round-leaved plant known as khobbayza[17] are
pounded and made into a poultice to apply to their stings—it is said
with considerable effect. A native quack doctor from the Nile Valley
used to do a considerable trade in little blackish wafers of a
composition that he kept secret, which were also said to be very
beneficial not only against the stings of scorpions but also in the
case of snake bites. One of the native doctors I met in Mut tried them
on some of his patients with, he told me, great success. Very large,
hairy, yellow spiders, tarantulas perhaps, I saw once or twice, and
found the natives very much afraid of them.
In the Nile Valley, curious mud-built tables supported on a single
thick leg are used on which to place young children to secure them
from the attacks of scorpions and tarantulas that, owing to the
overhang of the table, are unable to climb to the top. The table-top
itself is surrounded by a low wall to prevent the children from falling
off, the crest of the wall itself being often fantastically decorated.
I never came across any snakes at Dakhla, but more than once
saw the skin they had shed. There is said to be a long black snake,
generally found in or near the water channels, whose bite is
considered to be extremely dangerous. The ordinary horned
cerastes viper, though often met with in the desert, seems to be rare
in the oasis—and the same may be said of the unhorned viper that
so much resembles it at first sight. Insects swarm during the hot
weather in the oases. Butterflies are scarce, but moths are fairly
numerous. In Kharga I caught the cotton moth, but I did not see it in
Dakhla. Locusts are almost, I believe, unknown, but the grasshopper
tribe are in some parts—Tenida for instance—extremely numerous.

SCORPION-PROOF PLATFORM.

Bristle tails (silver fish) were unpleasantly destructive, and boring


bees do much damage by perforating the palm-trunk joists and
rafters of the houses and rendering them unsafe. House flies were
quite common enough to be a nuisance, though not to the extent
usually found in the Nile Valley. Mosquitoes were present in only
small numbers in Mut, owing probably to the scarcity of water in the
neighbourhood.
Dragon flies were conspicuously numerous—a dark red, a
greenish variety and a beautiful steely blue kind being, so far as I
saw, the most common.
In the spring there is a large immigration of birds into the oasis,
coming up from the south-west. Sand grouse—both a pintailed and a
spotted variety—are to be met with on the outskirts of the oasis and
in the parts of it remote from the villages. Quail, duck, snipe and
various water birds abound in the oasis at certain seasons. Kites I
never saw or heard, but eagles were several times seen. Also a bird
of the hawk species. Ravens exist in small numbers.
Pigeons are fairly well represented, a large wild pigeon—the blue
rock apparently, which lives largely in the cliffs surrounding the oasis
—being common. These at times give very good sport; in the open
they are far too wary to be approached within gun-shot. But in the
evening they come down to the wells to drink, usually choosing one
that is removed some distance from the villages.
But these pigeons proved to be very poor eating, their flesh being
hard and dry, and not to be compared with sand grouse for the pot.
The sand grouse, too, were singularly hard to bag. The only place
where I ever succeeded in shooting any was on the Gubary road
between Dakhla and Kharga Oases. I found them fairly numerous
there, being generally to be seen in the early morning at the places
where the bedawin camped for the night. As the day grew older they
left the road altogether and flew off into the desert.
The birds that interested me most in the oases were the kimri, or
palm doves. There are at least two kinds in Dakhla, the kimri beladi,
or local palm dove, and the kimri sifi, or summer dove. The former
seems to be resident in Dakhla all the year round; but the latter are
migrants, coming into the oasis in March and returning in the autumn
after the date harvest. They take somewhat the place in Dakhla that
the cuckoo does in England, their advent being regarded as a sign
that the winter is past and the summer close at hand. The palm
groves of the oasis, when the hot weather comes on, swarm with
these pretty little birds, whose soft cooing as they sit swaying in the
palm tops is a most melodious sound—extremely pleasant and
soothing after a long hot desert journey.
The whole question of the animal and vegetable life in these
desolate regions is one of great interest. In spite of the intensely arid
nature of these deserts, they support in some marvellous way a
considerable amount of life.
Small lizards were often to be seen in the desert scuttling about
the ground. They run with extraordinary speed, and are very difficult
to catch. The usual way, I believe, is to throw a handkerchief on the
ground and to drive the lizard towards it, when it will frequently run
under the handkerchief to shelter, and can then be easily picked up. I
found that, though they could run very fast for a short distance, they
very soon tired, and, if steadily followed up for a hundred yards,
without allowing them time to rest, they became so exhausted that
they could be easily secured.
I never saw a specimen of the waran, or large lizard, in the desert,
but on one occasion saw what looked like its track. It resembled the
trail of a large-bodied lizard crawling slowly over the sand. My men,
however, declared it to be the track of an issulla, which they
described as a creature between a snake and a lizard in shape,
which, when approached, will fly at an intruder, rising into the air
after a rapid run on membraneous wings stretched between its legs
—acting apparently somewhat like an aeroplane. They said its bite
was poisonous, and generally fatal, but that, if it failed to strike home
during its flight, it fell on the ground and burst! The existence of such
a reptile—if we exclude the bursting part of the story—is perhaps not
absolutely impossible. One has to take native statements of this kind
with more than the usual amount of salt; but it does not do to ignore
them entirely.
Its track corresponded well with the description of the reptile given
me by my men, for, outside the marks where its feet had been
placed, something had clearly been dragged along the sand, leaving
a trace that showed upon its surface as a scratch. What that
“something” was it is difficult to say—unless, as my men declared, it
was part of the membrane upon which the issulla is said to sail
through the air. It could not have been caused by its tail, as it
appeared in places upon both sides of the track at once.
With regard to the capacity it is said to have of being able to rise
into the air from the ground, that, I think, presents but little difficulty. I
gathered from my men’s account that it would have been nearly
three feet long. The small fast-running lizards previously mentioned
are mostly under six inches in length, and must be able to travel at
nearly ten miles an hour, as it takes a man on foot all his time to
catch them up. As the issulla must be five times the length of these
little lizards, it is not unreasonable to assume that it can run quite
twice as fast, or say at twenty miles an hour, which, if it were running
against a stiffish breeze, would be equivalent to say fifty miles an
hour through the air—a speed that would probably easily cause it to
rise from the ground—but it is a tall story.
Snakes are very common in the desert—the lefa’a, or horned
viper, and a very similar viper without horns being in places rather
unpleasantly numerous. In addition we killed a very thin sandy-
coloured snake, about four feet in length, which, so far as I could
judge from its head, did not appear to be poisonous. The naja, or
Egyptian cobra, sometimes seen in the Nile Valley, is, I believe, quite
unknown in the desert and oases.
I several times heard rumours of a feathered snake. At first I put
this down as being a myth, but I afterwards found that this creature
had been seen by at least one European, who had been long
resident in the country. The specimen he saw was one killed in the
Nile Valley. He described it as being a short, stout, sandy-coloured
snake, having along its back, for some distance behind its head, a
sort of crest of elongated scales considerably frayed out at their
ends.
The existence of this creature is by no means an impossibility, for
reptiles and birds are closely related.
Insects in the desert are comparatively few in number. I once
found a few small ants, pink and silver in colour. Large grotesque-
looking mantids were often seen running about on the sandy
portions of the desert. Some of them were of considerable size,
many of them being quite three inches long. They were curious
creatures, and apparently very pugnacious, as, when approached,
they would often turn round and face me, raising themselves slightly
on their squat fat bodies and pawing the air with their big front legs.
If I pushed my foot towards them they frequently attacked it,
grappling my toe with their legs and trying to bite. I picked up one of
the larger ones and gave him the end of my thumb to bite—a rather
foolish proceeding, it struck me afterwards, as, for all I knew to the
contrary, his bite might have been poisonous. He bit furiously at the
end of my thumb with his rather formidable jaws, foaming at the
mouth and doing his feeble best to damage me. He managed to get
hold of a small pinch of skin between his jaws, which closed in a
horizontal direction, and gave me a nip I could distinctly feel.
Once, in the desert west of Dakhla, I found a mosquito, which
considerably raised my hopes that I might be getting near water. But
it proved to be only a wind-born specimen, coming probably from
Nesla or Bu Mungar. Lace-winged flies frequently came into our
camp, even when far out into the desert, and on most nights a few
moths flew into my tent and came to my candle; occasionally they
were in considerable numbers.
The common house flies, though a nuisance in the oasis, are
fortunately unknown in the desert, though frequently a swarm of
them, if there is no wind, will follow a caravan when starting from an
oasis; but they disappear in a day or two.
Once while riding in a desert with my caravan, when, having left
an oasis the day before, we were considerably bothered with these
pests, a swarm of which kept buzzing round our heads, I was
relieved of them in a rather unexpected manner. A swallow—
evidently migrating—came up to the caravan from the south, and
being presumably very hungry, kept flying round and round our
heads, snapping up a fly at every circle. Owing probably to its
hunger, the little creature was extraordinarily tame—its wing tips
several times almost touched my face. Having remained with the
caravan for a few minutes, it circled round us half a dozen times to
make sure that there were no flies that it had overlooked, and then
flew off and pursued its way to the north.
A list of some of the insects I collected will be found in Appendix
II.
The road that we followed to the south-west from Dakhla lay in the
direction from which the birds were migrating, so I not only noted
every specimen that we saw, but put down in my route book every
feather that I picked up, and even the marks on the sand where
these migrants had alighted, as this was all valuable evidence that
we were still travelling in the right direction.
In addition to palm doves and the smaller migrants, we several
times saw storks and cranes, or their tracks; but this, of course, only
occurred during the season of their migration. There was a large
white bird, which appeared to be an eagle, that we frequently saw at
all seasons, but I was never able to get very close to it, as, unlike
most desert creatures, it was extremely wild.
The only place where I ever saw any sand grouse, outside the
oases, was on the road between Kharga and Dakhla. They seemed
to be entirely absent from the desert to the south and south-west of
Dakhla, and also from the desert surrounding Farafra Oasis—the
reason of their absence presumably being the lack of food.
Not only were insects, reptiles and birds fairly well represented in
the desert, but even mammals were not unknown. In addition to the
desert rats, about eighty miles to the south of Dakhla I came across
the remains of a gazelle, but possibly the poor little beast had only
wandered out into the desert to die. Small foxes, though they existed
in the oasis, I never saw in the desert—the rats would not have been
so numerous if I had. The tracks of a larger fox were seen several
times, often several days’ journey away from an oasis. The tracks of
jackals, or wolves, I could not be sure which, were still oftener
encountered.
The dog tribe, of course, could live on the rats and lizards, but,
unless they obtained sufficient moisture from the blood of their
victims, they must have returned occasionally to the oases to drink.
One wonders why these animals, who can live also in the oases,
should prefer to exist in the desert, where the conditions under which
they are forced to live must make life almost impossible.
The problem of how the desert rats exist has caused much
discussion, and cannot yet be said to be solved. I have found them
certainly a good hundred and fifty miles from any oasis, in a part
quite barren, yet they were obviously perfectly healthy, plump and
lively.
I was once camped for several weeks in the dune belt that runs
through Kharga Oasis. One evening I had just sat down to dinner,
when I noticed one of these little kangaroo rats hopping about in the
candle-light just outside the door of my tent. A sudden movement
that I made scared him. He jumped about four feet and was gone in
a flash.
But in a minute or two, prompted probably by curiosity, he was
back again in his old place, hovering about just outside the tent.
Hoping to get a better look at him, I flipped a small piece of bread so
that it fell just in front of him. After some hesitation, he pounced on to
it, and carrying it a few yards away, proceeded to eat it.
He then came back again, stationing himself a little nearer in, and
seized another piece of bread I threw him that dropped about half-
way between us. Soon I had him taking pieces actually out of my
hand—he was extraordinarily tame.
I was just finishing my meal, and had forgotten all about him, and
was reading a book propped up on the table as I ate, when I
suddenly felt a tap on the top of my thigh, and on looking down to
see what it was, found that he had not only returned, but had actually
jumped up on to my leg as I sat at table. In a moment more, he had
hopped up on to the table itself and was eating the crumbs.
He was so absolutely fearless that he even allowed me to stroke
his back with my finger; but directly I attempted to close my hand
over him he jumped off the table in alarm on to the ground, where,
however, he remained restlessly hopping about with his
extraordinarily springy movement, till I threw him another piece of
bread.
Apparently, however, he had had as much as he wanted for the
moment, for, instead of eating it as he had done before, he picked it
up, hopped out of the tent, and disappeared for several minutes.
Presently, however, he came back again. I threw him another piece
that he again made off with, and after an interval returned for more.
He must have carried off about ten pieces in this way that evening,
each piece about the size of a filbert. I kept on feeding him so long
as he continued to return; but at last, being perhaps tired after
carrying so often what must have been a heavy load for him, he
ceased to appear.
He returned again on the following night, and for eight
consecutive ones. Each night I gave him as much bread as he would
eat and carry away. He seemed to be a very small eater; but he must
have taken off with him enough bread to make two or three loaves.
In addition, he levied toll on the grain for the camels, which he
obtained by gnawing holes in the sacks.
This last, however, proved to be his undoing, for one of my men
happened to catch him in the act, and promptly, much to my disgust,
killed him. It was unquestionably the same rat that had come nightly
to my tent that had also carried off the grain, for there was no
possibility of mistaking him, owing to the fact that he had lost an eye.
I felt quite sorry to lose the little beast, which had become quite a
pet, and latterly became so tame that he would allow me to pick him
up and stroke him. When my man, however, grabbed hold of him in
his hand, he promptly bit him in the thumb.
These little kangaroo rats are wonderfully pretty little creatures,
just the colour of the sand itself, with large black eyes and a very
long tail. Their most striking peculiarity is the enormous muscular
development of their hind legs, which seem quite disproportionately
massive in comparison with their small bodies.
It is this great muscular development of their long hind legs that
gives them such wonderful powers of locomotion. Once, while
travelling with my caravan over a large area of level sand, I came
across the track of one of these rats, quite clearly visible on the
smooth surface, and as it happened to be travelling in practically the
same direction as I was going myself, I followed it for a long
distance.
The track consisted of a series of double dots where the hind feet
had landed on the sand, occurring at regular intervals of three to four
feet apart. I followed those tracks for over nine miles in practically a
straight line, till a change in the direction of my route from that of the
rat compelled me to leave them.
During the whole of the time during which I followed them, I only
found three or four places where the rat had abandoned his regular
pace and stopped for a moment or two to turn round and round
apparently to play with his tail.
The speed at which these little beasts can travel is little short of
marvellous. The fastest runner would not have the remotest chance
of catching them; when frightened, they will go off at a pace that the
natives say even a horse cannot equal. The steady rate which the
one whose tracks I had followed had kept up for so many miles,
shows that they can travel long distances without tiring, and that they
not only can, but do.
It is in this marvellous capacity for getting over the ground, and
their habit of hoarding up provisions, that the explanation of their
ability to live in these districts can, I believe, be found.
Absolutely barren as this district seems to be, there are here and
there patches of grass, quite dead to all appearances, but which
have probably shed their seed on the surrounding ground. Even in
these arid districts rain is not unknown—there were stories in Dakhla
of a regular downpour that was said to have occurred not many
years before, when rain fell in such quantities that many of the mud-
built houses of the oasis melted before it and fell down. Rainfall such
as this, or even a heavy shower, might cause the seed to sprout. The
grass is usually found growing on the stiffest clay, which would hold

You might also like